Can you put together a small unit test[1] that recreates the issue? [1] https://openjpa.apache.org/writing-test-cases-for-openjpa.html
Thanks, Rick On Sat, Mar 22, 2014 at 6:53 PM, Alain Brazeau <abraz...@rogers.com> wrote: > My application has the following bidirectional one-to-many association: > > @Entity > @Table(name="TB_CUSTOMERS") > public class Customer { > > @OneToMany(mappedBy="customer", cascade={CascadeType.PERSIST, > CascadeType.REMOVE}) > @OrderBy("createdDate DESC") > private List<Order> orders = new ArrayList<Order>(); > > ... > > } > > @Entity > @Table(name="TB_ORDERS") > public class Order { > > @ManyToOne > @JoinColumn(name="CUSTOMER_ID") > private Customer customer; > > ... > > } > > I recently noticed that when a new Order object is added to a Customer > object's Order List, the underlying Customer database table record gets > updated, even though the Customer object was not modified. This is > especially problematic since I have a database trigger defined on the > Customer table that inserts the old version of a record in a Customer > history table for auditing purposes whenever an update occurs. > > I am currently using OpenJPA version 2.0.1. I have tried upgrading to > version 2.2.2, but still have the same problem. If I use Hibernate instead > of OpenJPA as the JPA implementation, the Customer database table does NOT > get updated. > > Based on my understanding of JPA, the Customer record should not get > updated > unless LockModeType.OPTIMISTIC_FORCE_INCREMENT is used (for optimistic > locking). > > In case it matters, I am using build time enhancement. Here is the > relevant > section from my Maven pom.xml file: > > <plugin> > <groupId>org.apache.openjpa</groupId> > <artifactId>openjpa-maven-plugin</artifactId> > <version>${openjpa.version}</version> > <configuration> > <addDefaultConstructor>true</addDefaultConstructor> > </configuration> > <executions> > <execution> > <id>enhancer</id> > <phase>process-classes</phase> > <goals> > <goal>enhance</goal> > </goals> > </execution> > </executions> > <dependencies> > <dependency> > <groupId>org.apache.openjpa</groupId> > <artifactId>openjpa</artifactId> > <version>${openjpa.version}</version> > </dependency> > </dependencies> > </plugin> > > Any help or advice would be greatly appreciated. > > > Thanks, > > > Alain > > > > > -- > View this message in context: > http://openjpa.208410.n2.nabble.com/Unecessary-database-update-tp7586121.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > -- *Rick Curtis*