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 <shikida@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
> <rmannibucau@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" <shikida@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
> > >
> >
>
|