Hello again Mark and Pinaki,

I've tried with the properties you mentioned Mark (and the one you mentioned
in your blog Pinaki). B ut I can see no difference. I also switched from
OpenJPA 2.0.1 to 2.1.1 but still no difference. My persistence.xml looks
like this:

*<?xml version="1.0" encoding="UTF-8"?>*
*<persistence 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"*
*  version="2.0">*
*  <persistence-unit name="maiaTestPU" transaction-type="RESOURCE_LOCAL">*
*
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>*
*    <class>se.digia.maia.core.bu.domain.BusinessUnit</class>*
*    <class>se.digia.maia.common.persistence.EntityBase</class>*
*    <class>se.digia.maia.common.security.domain.User</class>*
*    <class>se.digia.maia.common.auditlog.domain.AuditLogEntry</class>*
*    <exclude-unlisted-classes>true</exclude-unlisted-classes>*
*    <validation-mode>NONE</validation-mode>*
*    <properties>*
*      <property name="openjpa.RestoreState" value="all" />*
*      <property name="openjpa.DetachState"
value="loaded(DetachedStateField=true)" />*
*      <property name="openjpa.Compatibility"
value="IgnoreDetachedStateFieldForProxySerialization=true" />*
*      <property name="javax.persistence.jdbc.password" value="root" />*
*      <property name="javax.persistence.jdbc.user" value="root" />*
*      <property name="javax.persistence.jdbc.driver"
value="com.mysql.jdbc.Driver" />*
*      <property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost:3306/maia?createDatabaseIfNotExist=true" />*
*      <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />*
*      <property name="openjpa.jdbc.DBDictionary"
value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />*
*      <property name="openjpa.jdbc.UpdateManager" value="operation-order"
/>*
*      <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />*
*    </properties>*
*  </persistence-unit>*
*</persistence>*

My JUnit test case look like this:

*    ...*
*    // Create the business unit*
*    cEntityManager.getTransaction().begin();*
*    BusinessUnit bu = createPersistentBusinessUnit("Created", "Created
department");*
*    cEntityManager.getTransaction().commit();*
*
*
*    // Update the business unit*
*    cEntityManager.getTransaction().begin();*
*    BusinessUnit bu2 = cEntityManager.find(BusinessUnit.class, bu.getId());
*
*    bu2.setShortName("Updated");*
*    bu2.setName("Updated too");*
*    cEntityManager.merge(bu2);*
*    cEntityManager.getTransaction().commit(); //  Throws an exception*
*
*
*    // Verify business unit*
*    BusinessUnit bu3 = cEntityManager.find(BusinessUnit.class, bu.getId());
*
*    assertEquals(bu.getId(), bu3.getId());*
*    assertEquals(bu.getShortName(), bu3.getShortName());*
*    assertEquals(bu.getName(), bu3.getName());*

The @PreUpdate callback is as I mentioned in a previous post. The marked
line (with a comment) throws an exception. The reason is that mandatory
values are missing. Values that exist in the persisted entity (variable
"bu") but are not updated. If I remove the audit logging from my @PreUpdate
method, the JUnit test case succeeds.

Any clues?

/Bengt


2011/7/21 Bengt Rodehav <be...@rodehav.com>

> I'm currently in Turkey on vacation but will try when I get back to Sweden.
> /Bengt
> Den 19 jul 2011 17:48 skrev "Pinaki Poddar" <ppod...@apache.org>:
>
> > Hi Bengt,
> > It is not obvious to me how DetachState related options will impact
> > in-transaction entities. But I am interested to know the result of your
> > experiment with the options Mark has suggested.
> >
> > I will recommend you make sure the following
> > 1. Enhance at build time
> > 2. Set openjpa.RestoreState=true
> >
> >
> >
> >
> > -----
> > Pinaki Poddar
> > Chair, Apache OpenJPA Project
> > --
> > View this message in context:
> http://openjpa.208410.n2.nabble.com/Audit-log-with-OpenJPA-tp6557932p6599036.html
> > Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Reply via email to