You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "Leonardo K. Shikida" <sh...@gmail.com> on 2013/10/11 04:21:03 UTC
@Auditable not working
Hi
I am trying to use OpenJPA @Auditable with tomee+ 1.5.2 but something
strange is happening.
persistence.xml has
<property name="openjpa.Auditor" value="xxx.Auditor"/>
my class xxx.Auditor
public class Auditor implements org.apache.openjpa.audit.Auditor {
@Override
public void endConfiguration() {
// TODO Auto-generated method stub
System.out.println("works");
}
@Override
public void setConfiguration(Configuration arg0) {
// TODO Auto-generated method stub
System.out.println("works");
}
@Override
public void startConfiguration() {
// TODO Auto-generated method stub
System.out.println("works");
}
@Override
public void close() throws Exception {
// TODO Auto-generated method stub
}
@Override
public void audit(Broker arg0, Collection<Audited> arg1,
Collection<Audited> arg2, Collection<Audited> arg3) {
System.out.println("?");
System.out.println(arg1);
System.out.println(arg2);
System.out.println(arg3);
}
@Override
public boolean isRollbackOnError() {
// TODO Auto-generated method stub
return false;
}
}
and the auditable class
@Entity
@Auditable
@Table(uniqueConstraints=@UniqueConstraint(columnNames={"description"}))
public class Application implements Serializable {
/**
*
*/
private static final long serialVersionUID = 6119051520445701552L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
(...)
I am deleting/inserting/editing the Application class but it seems the
audit() method is not being called, while endConfiguration(),
setConfiguration(), and startConfiguration() are.
I am running from inside eclipse, no stacktrace detected. Entity classes
are being enhanced on build.
TIA
Leo
Re: @Auditable not working
Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
OK
I've tested with an old 1.6.0 snapshot I had here (August) and the bug
remains.
I'm testing with the newest snapshots (both 1.5.3 and 1.6.0) and if the bug
persists, I'll fill a bug.
TIA
Leo
[]
Leo
On Fri, Oct 11, 2013 at 12:23 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:
> I don't know but 1.5.3 would need a lot of work to fix regression
> introduced in 1.5.2 so I'd rather bet on 1.6 personally.
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/10/11 Leonardo K. Shikida <sh...@gmail.com>
>
> > Hi Romain
> >
> > Is it reasonable to submit a bug to 1.5.2 or it's frozen until 1.6.x
> stable
> > release?
> >
> > TIA
> >
> > Leo
> >
> > []
> >
> > Leo
> >
> >
> > On Fri, Oct 11, 2013 at 12:14 PM, Romain Manni-Bucau
> > <rm...@gmail.com>wrote:
> >
> > > well it worked locally on the snapshot.
> > >
> > > PS: if you don't package it to be easily runnable (basically: git clone
> > XXX
> > > && cd XXX && mvn clean install # or ant) i can't guarantee you i'll
> test
> > > it)
> > >
> > > *Romain Manni-Bucau*
> > > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > > *Blog: **http://rmannibucau.wordpress.com/*<
> > > http://rmannibucau.wordpress.com/>
> > > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > > *Github: https://github.com/rmannibucau*
> > >
> > >
> > >
> > > 2013/10/11 Leonardo K. Shikida <sh...@gmail.com>
> > >
> > > > Hi Romain
> > > >
> > > > I can't think on anything simpler that this :-)
> > > >
> > > > I am using java7, eclipse indigo and tomee+ 1.5.2
> > > >
> > > > TIA
> > > >
> > > > Leo
> > > >
> > > >
> > > >
> > >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MyAuditTest>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > > > package ejb;
> > > >
> > > > import javax.ejb.Schedule;
> > > > import javax.ejb.Startup;
> > > > import javax.ejb.Stateless;
> > > > import javax.persistence.EntityManager;
> > > > import javax.persistence.PersistenceContext;
> > > >
> > > > import entities.SomePersistentEntity;
> > > >
> > > > @Stateless
> > > > @Startup
> > > > public class MyAuditTest {
> > > >
> > > > @PersistenceContext(unitName = "poc")
> > > > private EntityManager entityManager;
> > > >
> > > > @Schedule(minute = "*", hour = "*")
> > > > public void save(){
> > > > System.out.println("Saving...");
> > > > SomePersistentEntity entity = new SomePersistentEntity();
> > > > entity.setS(String.valueOf(System.currentTimeMillis()));
> > > > entityManager.persist(entity);
> > > > }
> > > > }
> > > >
> > > >
> > > >
> > >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>SomePersistentEntity>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > > > package entities;
> > > >
> > > > import java.io.Serializable;
> > > >
> > > > import javax.persistence.Entity;
> > > > import javax.persistence.GeneratedValue;
> > > > import javax.persistence.GenerationType;
> > > > import javax.persistence.Id;
> > > >
> > > > import org.apache.openjpa.audit.Auditable;
> > > >
> > > > @Entity
> > > > @Auditable
> > > > public class SomePersistentEntity implements Serializable {
> > > > /**
> > > > *
> > > > */
> > > > private static final long serialVersionUID =
> 6119051520445701552L;
> > > >
> > > > @Id
> > > > @GeneratedValue(strategy = GenerationType.AUTO)
> > > > private Long id;
> > > >
> > > > private String s;
> > > >
> > > > public Long getId() {
> > > > return id;
> > > > }
> > > >
> > > > public void setId(Long id) {
> > > > this.id = id;
> > > > }
> > > >
> > > > public String getS() {
> > > > return s;
> > > > }
> > > >
> > > > public void setS(String s) {
> > > > this.s = s;
> > > > }
> > > >
> > > >
> > > > }
> > > >
> > > >
> > > >
> > >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>persistence.xml>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > > >
> > > >
> > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > <persistence version="2.0" xmlns="
> > http://java.sun.com/xml/ns/persistence
> > > "
> > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > xsi:schemaLocation="
> > > > http://java.sun.com/xml/ns/persistence
> > > > http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
> > > > <persistence-unit name="poc">
> > > > <jta-data-source>poc1</jta-data-source>
> > > > <non-jta-data-source>poc2</non-jta-data-source>
> > > > <properties>
> > > > <property name="openjpa.jdbc.DBDictionary"
> > > > value="oracle(maxEmbeddedBlobSize=-1,maxEmbeddedClobSize=-1)"/>
> > > > <property name="openjpa.jdbc.SynchronizeMappings"
> > > > value="buildSchema(ForeignKeys=true)"/>
> > > > <property name="openjpa.Auditor" value="default"/>
> > > > </properties>
> > > > </persistence-unit>
> > > > </persistence>
> > > >
> > > >
> > > > []
> > > >
> > > > Leo
> > > >
> > > >
> > > > On Fri, Oct 11, 2013 at 1:52 AM, Romain Manni-Bucau
> > > > <rm...@gmail.com>wrote:
> > > >
> > > > > Hi
> > > > >
> > > > > Do you care putting it in a easily runnable project (mvn/ant on
> > > > github/code
> > > > > google for instance)?
> > > > > Le 11 oct. 2013 04:22, "Leonardo K. Shikida" <sh...@gmail.com> a
> > > > écrit :
> > > > >
> > > > > > Hi
> > > > > >
> > > > > > I am trying to use OpenJPA @Auditable with tomee+ 1.5.2 but
> > something
> > > > > > strange is happening.
> > > > > >
> > > > > > persistence.xml has
> > > > > >
> > > > > > <property name="openjpa.Auditor" value="xxx.Auditor"/>
> > > > > >
> > > > > > my class xxx.Auditor
> > > > > >
> > > > > > public class Auditor implements org.apache.openjpa.audit.Auditor
> {
> > > > > >
> > > > > > @Override
> > > > > > public void endConfiguration() {
> > > > > > // TODO Auto-generated method stub
> > > > > > System.out.println("works");
> > > > > > }
> > > > > >
> > > > > > @Override
> > > > > > public void setConfiguration(Configuration arg0) {
> > > > > > // TODO Auto-generated method stub
> > > > > > System.out.println("works");
> > > > > > }
> > > > > >
> > > > > > @Override
> > > > > > public void startConfiguration() {
> > > > > > // TODO Auto-generated method stub
> > > > > > System.out.println("works");
> > > > > > }
> > > > > >
> > > > > > @Override
> > > > > > public void close() throws Exception {
> > > > > > // TODO Auto-generated method stub
> > > > > > }
> > > > > >
> > > > > > @Override
> > > > > > public void audit(Broker arg0, Collection<Audited> arg1,
> > > > > > Collection<Audited> arg2, Collection<Audited> arg3) {
> > > > > > System.out.println("?");
> > > > > > System.out.println(arg1);
> > > > > > System.out.println(arg2);
> > > > > > System.out.println(arg3);
> > > > > >
> > > > > > }
> > > > > >
> > > > > > @Override
> > > > > > public boolean isRollbackOnError() {
> > > > > > // TODO Auto-generated method stub
> > > > > > return false;
> > > > > > }
> > > > > >
> > > > > > }
> > > > > >
> > > > > > and the auditable class
> > > > > >
> > > > > > @Entity
> > > > > > @Auditable
> > > > > >
> > > >
> > @Table(uniqueConstraints=@UniqueConstraint(columnNames={"description"}))
> > > > > > public class Application implements Serializable {
> > > > > > /**
> > > > > > *
> > > > > > */
> > > > > > private static final long serialVersionUID =
> > > 6119051520445701552L;
> > > > > >
> > > > > > @Id
> > > > > > @GeneratedValue(strategy = GenerationType.AUTO)
> > > > > > private Long id;
> > > > > >
> > > > > > (...)
> > > > > >
> > > > > >
> > > > > > I am deleting/inserting/editing the Application class but it
> seems
> > > the
> > > > > > audit() method is not being called, while endConfiguration(),
> > > > > > setConfiguration(), and startConfiguration() are.
> > > > > >
> > > > > > I am running from inside eclipse, no stacktrace detected. Entity
> > > > classes
> > > > > > are being enhanced on build.
> > > > > >
> > > > > > TIA
> > > > > >
> > > > > > Leo
> > > > > >
> > > > >
> > > >
> > >
> >
>
Re: @Auditable not working
Posted by Romain Manni-Bucau <rm...@gmail.com>.
I don't know but 1.5.3 would need a lot of work to fix regression
introduced in 1.5.2 so I'd rather bet on 1.6 personally.
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/10/11 Leonardo K. Shikida <sh...@gmail.com>
> Hi Romain
>
> Is it reasonable to submit a bug to 1.5.2 or it's frozen until 1.6.x stable
> release?
>
> TIA
>
> Leo
>
> []
>
> Leo
>
>
> On Fri, Oct 11, 2013 at 12:14 PM, Romain Manni-Bucau
> <rm...@gmail.com>wrote:
>
> > well it worked locally on the snapshot.
> >
> > PS: if you don't package it to be easily runnable (basically: git clone
> XXX
> > && cd XXX && mvn clean install # or ant) i can't guarantee you i'll test
> > it)
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> > 2013/10/11 Leonardo K. Shikida <sh...@gmail.com>
> >
> > > Hi Romain
> > >
> > > I can't think on anything simpler that this :-)
> > >
> > > I am using java7, eclipse indigo and tomee+ 1.5.2
> > >
> > > TIA
> > >
> > > Leo
> > >
> > >
> > >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MyAuditTest>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > > package ejb;
> > >
> > > import javax.ejb.Schedule;
> > > import javax.ejb.Startup;
> > > import javax.ejb.Stateless;
> > > import javax.persistence.EntityManager;
> > > import javax.persistence.PersistenceContext;
> > >
> > > import entities.SomePersistentEntity;
> > >
> > > @Stateless
> > > @Startup
> > > public class MyAuditTest {
> > >
> > > @PersistenceContext(unitName = "poc")
> > > private EntityManager entityManager;
> > >
> > > @Schedule(minute = "*", hour = "*")
> > > public void save(){
> > > System.out.println("Saving...");
> > > SomePersistentEntity entity = new SomePersistentEntity();
> > > entity.setS(String.valueOf(System.currentTimeMillis()));
> > > entityManager.persist(entity);
> > > }
> > > }
> > >
> > >
> > >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>SomePersistentEntity>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > > package entities;
> > >
> > > import java.io.Serializable;
> > >
> > > import javax.persistence.Entity;
> > > import javax.persistence.GeneratedValue;
> > > import javax.persistence.GenerationType;
> > > import javax.persistence.Id;
> > >
> > > import org.apache.openjpa.audit.Auditable;
> > >
> > > @Entity
> > > @Auditable
> > > public class SomePersistentEntity implements Serializable {
> > > /**
> > > *
> > > */
> > > private static final long serialVersionUID = 6119051520445701552L;
> > >
> > > @Id
> > > @GeneratedValue(strategy = GenerationType.AUTO)
> > > private Long id;
> > >
> > > private String s;
> > >
> > > public Long getId() {
> > > return id;
> > > }
> > >
> > > public void setId(Long id) {
> > > this.id = id;
> > > }
> > >
> > > public String getS() {
> > > return s;
> > > }
> > >
> > > public void setS(String s) {
> > > this.s = s;
> > > }
> > >
> > >
> > > }
> > >
> > >
> > >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>persistence.xml>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > >
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <persistence version="2.0" xmlns="
> http://java.sun.com/xml/ns/persistence
> > "
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="
> > > http://java.sun.com/xml/ns/persistence
> > > http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
> > > <persistence-unit name="poc">
> > > <jta-data-source>poc1</jta-data-source>
> > > <non-jta-data-source>poc2</non-jta-data-source>
> > > <properties>
> > > <property name="openjpa.jdbc.DBDictionary"
> > > value="oracle(maxEmbeddedBlobSize=-1,maxEmbeddedClobSize=-1)"/>
> > > <property name="openjpa.jdbc.SynchronizeMappings"
> > > value="buildSchema(ForeignKeys=true)"/>
> > > <property name="openjpa.Auditor" value="default"/>
> > > </properties>
> > > </persistence-unit>
> > > </persistence>
> > >
> > >
> > > []
> > >
> > > Leo
> > >
> > >
> > > On Fri, Oct 11, 2013 at 1:52 AM, Romain Manni-Bucau
> > > <rm...@gmail.com>wrote:
> > >
> > > > Hi
> > > >
> > > > Do you care putting it in a easily runnable project (mvn/ant on
> > > github/code
> > > > google for instance)?
> > > > Le 11 oct. 2013 04:22, "Leonardo K. Shikida" <sh...@gmail.com> a
> > > écrit :
> > > >
> > > > > Hi
> > > > >
> > > > > I am trying to use OpenJPA @Auditable with tomee+ 1.5.2 but
> something
> > > > > strange is happening.
> > > > >
> > > > > persistence.xml has
> > > > >
> > > > > <property name="openjpa.Auditor" value="xxx.Auditor"/>
> > > > >
> > > > > my class xxx.Auditor
> > > > >
> > > > > public class Auditor implements org.apache.openjpa.audit.Auditor {
> > > > >
> > > > > @Override
> > > > > public void endConfiguration() {
> > > > > // TODO Auto-generated method stub
> > > > > System.out.println("works");
> > > > > }
> > > > >
> > > > > @Override
> > > > > public void setConfiguration(Configuration arg0) {
> > > > > // TODO Auto-generated method stub
> > > > > System.out.println("works");
> > > > > }
> > > > >
> > > > > @Override
> > > > > public void startConfiguration() {
> > > > > // TODO Auto-generated method stub
> > > > > System.out.println("works");
> > > > > }
> > > > >
> > > > > @Override
> > > > > public void close() throws Exception {
> > > > > // TODO Auto-generated method stub
> > > > > }
> > > > >
> > > > > @Override
> > > > > public void audit(Broker arg0, Collection<Audited> arg1,
> > > > > Collection<Audited> arg2, Collection<Audited> arg3) {
> > > > > System.out.println("?");
> > > > > System.out.println(arg1);
> > > > > System.out.println(arg2);
> > > > > System.out.println(arg3);
> > > > >
> > > > > }
> > > > >
> > > > > @Override
> > > > > public boolean isRollbackOnError() {
> > > > > // TODO Auto-generated method stub
> > > > > return false;
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > > and the auditable class
> > > > >
> > > > > @Entity
> > > > > @Auditable
> > > > >
> > >
> @Table(uniqueConstraints=@UniqueConstraint(columnNames={"description"}))
> > > > > public class Application implements Serializable {
> > > > > /**
> > > > > *
> > > > > */
> > > > > private static final long serialVersionUID =
> > 6119051520445701552L;
> > > > >
> > > > > @Id
> > > > > @GeneratedValue(strategy = GenerationType.AUTO)
> > > > > private Long id;
> > > > >
> > > > > (...)
> > > > >
> > > > >
> > > > > I am deleting/inserting/editing the Application class but it seems
> > the
> > > > > audit() method is not being called, while endConfiguration(),
> > > > > setConfiguration(), and startConfiguration() are.
> > > > >
> > > > > I am running from inside eclipse, no stacktrace detected. Entity
> > > classes
> > > > > are being enhanced on build.
> > > > >
> > > > > TIA
> > > > >
> > > > > Leo
> > > > >
> > > >
> > >
> >
>
Re: @Auditable not working
Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
Hi Romain
Is it reasonable to submit a bug to 1.5.2 or it's frozen until 1.6.x stable
release?
TIA
Leo
[]
Leo
On Fri, Oct 11, 2013 at 12:14 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:
> well it worked locally on the snapshot.
>
> PS: if you don't package it to be easily runnable (basically: git clone XXX
> && cd XXX && mvn clean install # or ant) i can't guarantee you i'll test
> it)
>
> *Romain Manni-Bucau*
> *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> *Blog: **http://rmannibucau.wordpress.com/*<
> http://rmannibucau.wordpress.com/>
> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> *Github: https://github.com/rmannibucau*
>
>
>
> 2013/10/11 Leonardo K. Shikida <sh...@gmail.com>
>
> > Hi Romain
> >
> > I can't think on anything simpler that this :-)
> >
> > I am using java7, eclipse indigo and tomee+ 1.5.2
> >
> > TIA
> >
> > Leo
> >
> >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MyAuditTest>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > package ejb;
> >
> > import javax.ejb.Schedule;
> > import javax.ejb.Startup;
> > import javax.ejb.Stateless;
> > import javax.persistence.EntityManager;
> > import javax.persistence.PersistenceContext;
> >
> > import entities.SomePersistentEntity;
> >
> > @Stateless
> > @Startup
> > public class MyAuditTest {
> >
> > @PersistenceContext(unitName = "poc")
> > private EntityManager entityManager;
> >
> > @Schedule(minute = "*", hour = "*")
> > public void save(){
> > System.out.println("Saving...");
> > SomePersistentEntity entity = new SomePersistentEntity();
> > entity.setS(String.valueOf(System.currentTimeMillis()));
> > entityManager.persist(entity);
> > }
> > }
> >
> >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>SomePersistentEntity>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> > package entities;
> >
> > import java.io.Serializable;
> >
> > import javax.persistence.Entity;
> > import javax.persistence.GeneratedValue;
> > import javax.persistence.GenerationType;
> > import javax.persistence.Id;
> >
> > import org.apache.openjpa.audit.Auditable;
> >
> > @Entity
> > @Auditable
> > public class SomePersistentEntity implements Serializable {
> > /**
> > *
> > */
> > private static final long serialVersionUID = 6119051520445701552L;
> >
> > @Id
> > @GeneratedValue(strategy = GenerationType.AUTO)
> > private Long id;
> >
> > private String s;
> >
> > public Long getId() {
> > return id;
> > }
> >
> > public void setId(Long id) {
> > this.id = id;
> > }
> >
> > public String getS() {
> > return s;
> > }
> >
> > public void setS(String s) {
> > this.s = s;
> > }
> >
> >
> > }
> >
> >
> >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>persistence.xml>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence
> "
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="
> > http://java.sun.com/xml/ns/persistence
> > http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
> > <persistence-unit name="poc">
> > <jta-data-source>poc1</jta-data-source>
> > <non-jta-data-source>poc2</non-jta-data-source>
> > <properties>
> > <property name="openjpa.jdbc.DBDictionary"
> > value="oracle(maxEmbeddedBlobSize=-1,maxEmbeddedClobSize=-1)"/>
> > <property name="openjpa.jdbc.SynchronizeMappings"
> > value="buildSchema(ForeignKeys=true)"/>
> > <property name="openjpa.Auditor" value="default"/>
> > </properties>
> > </persistence-unit>
> > </persistence>
> >
> >
> > []
> >
> > Leo
> >
> >
> > On Fri, Oct 11, 2013 at 1:52 AM, Romain Manni-Bucau
> > <rm...@gmail.com>wrote:
> >
> > > Hi
> > >
> > > Do you care putting it in a easily runnable project (mvn/ant on
> > github/code
> > > google for instance)?
> > > Le 11 oct. 2013 04:22, "Leonardo K. Shikida" <sh...@gmail.com> a
> > écrit :
> > >
> > > > Hi
> > > >
> > > > I am trying to use OpenJPA @Auditable with tomee+ 1.5.2 but something
> > > > strange is happening.
> > > >
> > > > persistence.xml has
> > > >
> > > > <property name="openjpa.Auditor" value="xxx.Auditor"/>
> > > >
> > > > my class xxx.Auditor
> > > >
> > > > public class Auditor implements org.apache.openjpa.audit.Auditor {
> > > >
> > > > @Override
> > > > public void endConfiguration() {
> > > > // TODO Auto-generated method stub
> > > > System.out.println("works");
> > > > }
> > > >
> > > > @Override
> > > > public void setConfiguration(Configuration arg0) {
> > > > // TODO Auto-generated method stub
> > > > System.out.println("works");
> > > > }
> > > >
> > > > @Override
> > > > public void startConfiguration() {
> > > > // TODO Auto-generated method stub
> > > > System.out.println("works");
> > > > }
> > > >
> > > > @Override
> > > > public void close() throws Exception {
> > > > // TODO Auto-generated method stub
> > > > }
> > > >
> > > > @Override
> > > > public void audit(Broker arg0, Collection<Audited> arg1,
> > > > Collection<Audited> arg2, Collection<Audited> arg3) {
> > > > System.out.println("?");
> > > > System.out.println(arg1);
> > > > System.out.println(arg2);
> > > > System.out.println(arg3);
> > > >
> > > > }
> > > >
> > > > @Override
> > > > public boolean isRollbackOnError() {
> > > > // TODO Auto-generated method stub
> > > > return false;
> > > > }
> > > >
> > > > }
> > > >
> > > > and the auditable class
> > > >
> > > > @Entity
> > > > @Auditable
> > > >
> > @Table(uniqueConstraints=@UniqueConstraint(columnNames={"description"}))
> > > > public class Application implements Serializable {
> > > > /**
> > > > *
> > > > */
> > > > private static final long serialVersionUID =
> 6119051520445701552L;
> > > >
> > > > @Id
> > > > @GeneratedValue(strategy = GenerationType.AUTO)
> > > > private Long id;
> > > >
> > > > (...)
> > > >
> > > >
> > > > I am deleting/inserting/editing the Application class but it seems
> the
> > > > audit() method is not being called, while endConfiguration(),
> > > > setConfiguration(), and startConfiguration() are.
> > > >
> > > > I am running from inside eclipse, no stacktrace detected. Entity
> > classes
> > > > are being enhanced on build.
> > > >
> > > > TIA
> > > >
> > > > Leo
> > > >
> > >
> >
>
Re: @Auditable not working
Posted by Romain Manni-Bucau <rm...@gmail.com>.
well it worked locally on the snapshot.
PS: if you don't package it to be easily runnable (basically: git clone XXX
&& cd XXX && mvn clean install # or ant) i can't guarantee you i'll test it)
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/10/11 Leonardo K. Shikida <sh...@gmail.com>
> Hi Romain
>
> I can't think on anything simpler that this :-)
>
> I am using java7, eclipse indigo and tomee+ 1.5.2
>
> TIA
>
> Leo
>
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MyAuditTest>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> package ejb;
>
> import javax.ejb.Schedule;
> import javax.ejb.Startup;
> import javax.ejb.Stateless;
> import javax.persistence.EntityManager;
> import javax.persistence.PersistenceContext;
>
> import entities.SomePersistentEntity;
>
> @Stateless
> @Startup
> public class MyAuditTest {
>
> @PersistenceContext(unitName = "poc")
> private EntityManager entityManager;
>
> @Schedule(minute = "*", hour = "*")
> public void save(){
> System.out.println("Saving...");
> SomePersistentEntity entity = new SomePersistentEntity();
> entity.setS(String.valueOf(System.currentTimeMillis()));
> entityManager.persist(entity);
> }
> }
>
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>SomePersistentEntity>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> package entities;
>
> import java.io.Serializable;
>
> import javax.persistence.Entity;
> import javax.persistence.GeneratedValue;
> import javax.persistence.GenerationType;
> import javax.persistence.Id;
>
> import org.apache.openjpa.audit.Auditable;
>
> @Entity
> @Auditable
> public class SomePersistentEntity implements Serializable {
> /**
> *
> */
> private static final long serialVersionUID = 6119051520445701552L;
>
> @Id
> @GeneratedValue(strategy = GenerationType.AUTO)
> private Long id;
>
> private String s;
>
> public Long getId() {
> return id;
> }
>
> public void setId(Long id) {
> this.id = id;
> }
>
> public String getS() {
> return s;
> }
>
> public void setS(String s) {
> this.s = s;
> }
>
>
> }
>
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>persistence.xml>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
> <persistence-unit name="poc">
> <jta-data-source>poc1</jta-data-source>
> <non-jta-data-source>poc2</non-jta-data-source>
> <properties>
> <property name="openjpa.jdbc.DBDictionary"
> value="oracle(maxEmbeddedBlobSize=-1,maxEmbeddedClobSize=-1)"/>
> <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)"/>
> <property name="openjpa.Auditor" value="default"/>
> </properties>
> </persistence-unit>
> </persistence>
>
>
> []
>
> Leo
>
>
> On Fri, Oct 11, 2013 at 1:52 AM, Romain Manni-Bucau
> <rm...@gmail.com>wrote:
>
> > Hi
> >
> > Do you care putting it in a easily runnable project (mvn/ant on
> github/code
> > google for instance)?
> > Le 11 oct. 2013 04:22, "Leonardo K. Shikida" <sh...@gmail.com> a
> écrit :
> >
> > > Hi
> > >
> > > I am trying to use OpenJPA @Auditable with tomee+ 1.5.2 but something
> > > strange is happening.
> > >
> > > persistence.xml has
> > >
> > > <property name="openjpa.Auditor" value="xxx.Auditor"/>
> > >
> > > my class xxx.Auditor
> > >
> > > public class Auditor implements org.apache.openjpa.audit.Auditor {
> > >
> > > @Override
> > > public void endConfiguration() {
> > > // TODO Auto-generated method stub
> > > System.out.println("works");
> > > }
> > >
> > > @Override
> > > public void setConfiguration(Configuration arg0) {
> > > // TODO Auto-generated method stub
> > > System.out.println("works");
> > > }
> > >
> > > @Override
> > > public void startConfiguration() {
> > > // TODO Auto-generated method stub
> > > System.out.println("works");
> > > }
> > >
> > > @Override
> > > public void close() throws Exception {
> > > // TODO Auto-generated method stub
> > > }
> > >
> > > @Override
> > > public void audit(Broker arg0, Collection<Audited> arg1,
> > > Collection<Audited> arg2, Collection<Audited> arg3) {
> > > System.out.println("?");
> > > System.out.println(arg1);
> > > System.out.println(arg2);
> > > System.out.println(arg3);
> > >
> > > }
> > >
> > > @Override
> > > public boolean isRollbackOnError() {
> > > // TODO Auto-generated method stub
> > > return false;
> > > }
> > >
> > > }
> > >
> > > and the auditable class
> > >
> > > @Entity
> > > @Auditable
> > >
> @Table(uniqueConstraints=@UniqueConstraint(columnNames={"description"}))
> > > public class Application implements Serializable {
> > > /**
> > > *
> > > */
> > > private static final long serialVersionUID = 6119051520445701552L;
> > >
> > > @Id
> > > @GeneratedValue(strategy = GenerationType.AUTO)
> > > private Long id;
> > >
> > > (...)
> > >
> > >
> > > I am deleting/inserting/editing the Application class but it seems the
> > > audit() method is not being called, while endConfiguration(),
> > > setConfiguration(), and startConfiguration() are.
> > >
> > > I am running from inside eclipse, no stacktrace detected. Entity
> classes
> > > are being enhanced on build.
> > >
> > > TIA
> > >
> > > Leo
> > >
> >
>
Re: @Auditable not working
Posted by "Leonardo K. Shikida" <sh...@gmail.com>.
Hi Romain
I can't think on anything simpler that this :-)
I am using java7, eclipse indigo and tomee+ 1.5.2
TIA
Leo
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>MyAuditTest>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
package ejb;
import javax.ejb.Schedule;
import javax.ejb.Startup;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import entities.SomePersistentEntity;
@Stateless
@Startup
public class MyAuditTest {
@PersistenceContext(unitName = "poc")
private EntityManager entityManager;
@Schedule(minute = "*", hour = "*")
public void save(){
System.out.println("Saving...");
SomePersistentEntity entity = new SomePersistentEntity();
entity.setS(String.valueOf(System.currentTimeMillis()));
entityManager.persist(entity);
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>SomePersistentEntity>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
package entities;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.apache.openjpa.audit.Auditable;
@Entity
@Auditable
public class SomePersistentEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = 6119051520445701552L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String s;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getS() {
return s;
}
public void setS(String s) {
this.s = s;
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>persistence.xml>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="poc">
<jta-data-source>poc1</jta-data-source>
<non-jta-data-source>poc2</non-jta-data-source>
<properties>
<property name="openjpa.jdbc.DBDictionary"
value="oracle(maxEmbeddedBlobSize=-1,maxEmbeddedClobSize=-1)"/>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.Auditor" value="default"/>
</properties>
</persistence-unit>
</persistence>
[]
Leo
On Fri, Oct 11, 2013 at 1:52 AM, Romain Manni-Bucau
<rm...@gmail.com>wrote:
> Hi
>
> Do you care putting it in a easily runnable project (mvn/ant on github/code
> google for instance)?
> Le 11 oct. 2013 04:22, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :
>
> > Hi
> >
> > I am trying to use OpenJPA @Auditable with tomee+ 1.5.2 but something
> > strange is happening.
> >
> > persistence.xml has
> >
> > <property name="openjpa.Auditor" value="xxx.Auditor"/>
> >
> > my class xxx.Auditor
> >
> > public class Auditor implements org.apache.openjpa.audit.Auditor {
> >
> > @Override
> > public void endConfiguration() {
> > // TODO Auto-generated method stub
> > System.out.println("works");
> > }
> >
> > @Override
> > public void setConfiguration(Configuration arg0) {
> > // TODO Auto-generated method stub
> > System.out.println("works");
> > }
> >
> > @Override
> > public void startConfiguration() {
> > // TODO Auto-generated method stub
> > System.out.println("works");
> > }
> >
> > @Override
> > public void close() throws Exception {
> > // TODO Auto-generated method stub
> > }
> >
> > @Override
> > public void audit(Broker arg0, Collection<Audited> arg1,
> > Collection<Audited> arg2, Collection<Audited> arg3) {
> > System.out.println("?");
> > System.out.println(arg1);
> > System.out.println(arg2);
> > System.out.println(arg3);
> >
> > }
> >
> > @Override
> > public boolean isRollbackOnError() {
> > // TODO Auto-generated method stub
> > return false;
> > }
> >
> > }
> >
> > and the auditable class
> >
> > @Entity
> > @Auditable
> > @Table(uniqueConstraints=@UniqueConstraint(columnNames={"description"}))
> > public class Application implements Serializable {
> > /**
> > *
> > */
> > private static final long serialVersionUID = 6119051520445701552L;
> >
> > @Id
> > @GeneratedValue(strategy = GenerationType.AUTO)
> > private Long id;
> >
> > (...)
> >
> >
> > I am deleting/inserting/editing the Application class but it seems the
> > audit() method is not being called, while endConfiguration(),
> > setConfiguration(), and startConfiguration() are.
> >
> > I am running from inside eclipse, no stacktrace detected. Entity classes
> > are being enhanced on build.
> >
> > TIA
> >
> > Leo
> >
>
Re: @Auditable not working
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
Do you care putting it in a easily runnable project (mvn/ant on github/code
google for instance)?
Le 11 oct. 2013 04:22, "Leonardo K. Shikida" <sh...@gmail.com> a écrit :
> Hi
>
> I am trying to use OpenJPA @Auditable with tomee+ 1.5.2 but something
> strange is happening.
>
> persistence.xml has
>
> <property name="openjpa.Auditor" value="xxx.Auditor"/>
>
> my class xxx.Auditor
>
> public class Auditor implements org.apache.openjpa.audit.Auditor {
>
> @Override
> public void endConfiguration() {
> // TODO Auto-generated method stub
> System.out.println("works");
> }
>
> @Override
> public void setConfiguration(Configuration arg0) {
> // TODO Auto-generated method stub
> System.out.println("works");
> }
>
> @Override
> public void startConfiguration() {
> // TODO Auto-generated method stub
> System.out.println("works");
> }
>
> @Override
> public void close() throws Exception {
> // TODO Auto-generated method stub
> }
>
> @Override
> public void audit(Broker arg0, Collection<Audited> arg1,
> Collection<Audited> arg2, Collection<Audited> arg3) {
> System.out.println("?");
> System.out.println(arg1);
> System.out.println(arg2);
> System.out.println(arg3);
>
> }
>
> @Override
> public boolean isRollbackOnError() {
> // TODO Auto-generated method stub
> return false;
> }
>
> }
>
> and the auditable class
>
> @Entity
> @Auditable
> @Table(uniqueConstraints=@UniqueConstraint(columnNames={"description"}))
> public class Application implements Serializable {
> /**
> *
> */
> private static final long serialVersionUID = 6119051520445701552L;
>
> @Id
> @GeneratedValue(strategy = GenerationType.AUTO)
> private Long id;
>
> (...)
>
>
> I am deleting/inserting/editing the Application class but it seems the
> audit() method is not being called, while endConfiguration(),
> setConfiguration(), and startConfiguration() are.
>
> I am running from inside eclipse, no stacktrace detected. Entity classes
> are being enhanced on build.
>
> TIA
>
> Leo
>