Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
I'm using OpenJPA for persistence and would like to audit log any changes made to my entities. I serialize the objects to JSON (with Gson) and store them in a separate table in the database. Since the audit log needs to have the correct id's, the audit logging must take place after the entity has

Re: Audit log with OpenJPA

2011-07-07 Thread Jari Fredriksson
7.7.2011 14:05, Bengt Rodehav kirjoitti: I'm using OpenJPA for persistence and would like to audit log any changes made to my entities. I serialize the objects to JSON (with Gson) and store them in a separate table in the database. Since the audit log needs to have the correct id's, the audit

Re: Audit log with OpenJPA

2011-07-07 Thread David Goodenough
On Thursday 07 Jul 2011, Bengt Rodehav wrote: I'm using OpenJPA for persistence and would like to audit log any changes made to my entities. I serialize the objects to JSON (with Gson) and store them in a separate table in the database. Since the audit log needs to have the correct id's, the

AW: Audit log with OpenJPA

2011-07-07 Thread Boblitz John
-Ursprüngliche Nachricht- Von: David Goodenough [mailto:david.goodeno...@btconnect.com] Gesendet: Donnerstag, 7. Juli 2011 16:36 An: users@openjpa.apache.org Betreff: Re: Audit log with OpenJPA On Thursday 07 Jul 2011, Bengt Rodehav wrote: I'm using OpenJPA for persistence and

Re: Audit log with OpenJPA

2011-07-07 Thread Andrew Thompson
You might take a look at how hades (http://hades.synyx.org/static/2.x/site/org.synyx.hades/reference/html/auditing.html) does something close to what you're describing. Or http://www.jboss.org/envers -Andy On Thu, 2011-07-07 at 15:35 +0100, David Goodenough wrote: On Thursday 07 Jul 2011,

Re: Enhancement skipping field

2011-07-07 Thread Kevin Sutter
Why are we attempting to enhance a generated metamodel class? class com.spidertracks.aviator.model.user.Phone_ Classes that end in an underscore were probably generated for the metamodel and/or criteria API usage. So, something seems out of whack with attempting to enhance these classes. Kevin

Re: Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
Jari, Yes an asynchronous queue is definitely an option. I've actually used that approach before. It makes a lot of sense when trying to achieve high throughput since the audit logging can then be done on lower priority. I was however hoping to be able to use JPA for this since a queue increases

Re: Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
Thanks for your reply David, I wouldn't rule out cheating although I'd rather not. I have no experience in mixing JDBC and JPA. What would happen transaction wise? Can they both be part of the same transaction? /Bengt 2011/7/7 David Goodenough david.goodeno...@btconnect.com On Thursday 07 Jul

Re: Audit log with OpenJPA

2011-07-07 Thread Rick Curtis
Perhaps you could use a separate PU for your audit logging? That should be safe to use inside of a lifecycle callback. On Thu, Jul 7, 2011 at 11:36 AM, Bengt Rodehav be...@rodehav.com wrote: Jari, Yes an asynchronous queue is definitely an option. I've actually used that approach before. It

Re: Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
I actually use the same approach as Hades for createdBy, updatedBy, createdWhen and updatedWhen. In addition to this basic audit logging I also want to log all historical versions together with information about who updated the object. I've read a little bit about Envers. I didn't want to bring

Re: Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
Interesting suggestion. Can I still share the same transaction between the original update and my audit log insert? /Bengt 2011/7/7 Rick Curtis curti...@gmail.com Perhaps you could use a separate PU for your audit logging? That should be safe to use inside of a lifecycle callback. On Thu,

Re: Audit log with OpenJPA

2011-07-07 Thread Jari Fredriksson
How is your JPA accessed? I have done JPA, and Audit logging on top of it, but it was into XML files, and performed in a EJB3 Session Bean. The JPA objects were plain simple, but they were all accessed via a Session Bean Facade. I did it with XML because boss wanted so, but could have been

Re: Audit log with OpenJPA

2011-07-07 Thread No1UNo
Bengt: I'm enjoying this discussion because of the gymnastics that were required for my solutions. There is no easy way that I am aware of -- but I would LOVE to be wrong. Here's what I did (and, no, I'm not particularly proud of the solution): (1) For the primary entities, add tracking data

Re: Audit log with OpenJPA

2011-07-07 Thread Pinaki Poddar
Hi, Good to see lot of new ideas about auditing. Here is one more [1] that uses OpenJPA specific internals of accessing the original state of an entity. The comparison of the current state and original state to decide upon the audit message is provided trivially in this example -- but at the

Re: Audit log with OpenJPA

2011-07-07 Thread Mark Struberg
Hi Folks! I also use auditing with OpenJPA: http://struberg.wordpress.com/2010/07/31/howto-changelog-with-jpa/ but it currently only works with a patched OpenJPA 2.2.x version. https://issues.apache.org/jira/browse/OPENJPA-1873 We fixed a few parts already, but the POST_LOAD_ON_MERGE isn't yet

Re: Problems with load time enhancement and Spring's TomcatInstrumentableClassLoader

2011-07-07 Thread Pinaki Poddar
Hi, Following is from Rick's Spring reference [1] [1] http://static.springsource.org/spring/docs/2.0.x/reference/orm.html#orm-jpa-setup-lcemfb When is load time weaving required? Not all JPA providers impose the need of a JVM agent (Hibernate being an example). If your provider does not

Re: Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
Jarl, In production I run my application in OSGi (Apache Karaf). I use Apache Aries JPA support to publish entity manager factories and to enlist into JTA transactions. I've abandoned JEE since a while now - am even moving away from Spring I've also used XML before but I've recently moved

Re: Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
Wow - lots of discussion here. I must have hit a good topic for once... I don't see why you shouldn't be proud of your solution. Storing all versions is a well known idiom for preserving your history. Basically you don't allow updates but create new versions all the time instead. I have

Re: Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
Again an interesting approach. It's very similar to the way we did it in the old days (before O/R mappers were abundant). We rolled our own O/R mapping and also compared the previous state with the new state and saved the difference (XML in the database). I guess the same approach can be taken if

Re: Audit log with OpenJPA

2011-07-07 Thread Bengt Rodehav
Again an interesting solution. Although, as I wrote previously, I intend to store the whole object and therefore don't need to keep track of what has changed. I intend to do a JSON diff when viewing the audit log in the GUI instead. Your approach does, however, very elegantly solve the problem of

Re: Enhancement skipping field

2011-07-07 Thread Matthew Goodson
Hi, Kevin: We're using maven and it is picking up the Phone_ class and generating the warning here's the link for the uuid class that we're using https://github.com/stephenc/eaio-uuid/blob/master/src/main/java/com/eaio/uuid/UUID.java And the persistence xml... persistence

Re: Enhancement skipping field

2011-07-07 Thread Kevin Sutter
Hi Matthew, Not sure which maven plugin or ant script is being used for your build-time enhancement, but can it be modified to exclude the generated entity_ classes? These should not be run through the enhancer. Also, just to verify... You are generating these entity_ classes on purpose,

Re: Enhancement skipping field

2011-07-07 Thread Matthew Goodson
Yeah entity_ classes don't need to enhanced but the plugin doesn't exclude them but it doesn't affect the application so I'm not too worried. Its the Phone.id field that is not being enhanced that's causing my problem. Thanks On Fri, Jul 8, 2011 at 9:35 AM, Kevin Sutter kwsut...@gmail.com wrote:

Re: Audit log with OpenJPA

2011-07-07 Thread Pinaki Poddar
you actually store it in the object itself. That's right. This allows in-memory rollback. Given that the entire 'clean' or 'original' state is available in the technique I described, the application can make several decisions on a) what should be logged in an audit trail -- the entire object

Re: Audit log with OpenJPA

2011-07-07 Thread Pinaki Poddar
However, I store the JSON in a database and I was hoping to use JPA for this Actually, storing JSON in relational database would not permit query based on property values. But OpenJPA can provide JSON formatted-data for any web UI. To more about t, following references can help [1]

Re: Problems with load time enhancement and Spring's TomcatInstrumentableClassLoader

2011-07-07 Thread Andrew Thompson
Just to answer from my own perspective. The spring docs imply that both solutions are worst case equal and guide the naive user towards the weaver. I found out with experimentation that build time was the way to go. But even then that introduced a minute or two of build time in eclipse

Re: How to store a string array as a string array using jpa?

2011-07-07 Thread Suseendran.P
Thank you so much for ur reply..i go through the document.. First i have to say i'm very new to JPA.., i'm using javax.persistence related packages to annotate my class..means not using org.apache.openjpa.persistence related packages..in that document they gave JPA is not externalized can i mix