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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
poc1
poc2
[]
Leo
On Fri, Oct 11, 2013 at 1:52 AM, Romain Manni-Bucau
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" a écrit :
>
> > Hi
> >
> > I am trying to use OpenJPA @Auditable with tomee+ 1.5.2 but something
> > strange is happening.
> >
> > persistence.xml has
> >
> >
> >
> > 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 arg1,
> > Collection arg2, Collection 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
> >
>