3
votes

I was experimenting with eclipselink. I am trying to update an existing entity in database. The JPA entity only has public fields and fields are annotated with JPA annotation. The code loads an entity using EntityManager.find().

The code creates an instance of JPA entity, assigns value to public fields of the entity and invokes EntityManager.merge(entity) method. Eclipselink does not update database record. I enabled log to see whether Eclipselink issues SQL statement or not.

Eclipselink does not issue any update statement. Does this mean that even if I use field persistence, I can not assign value to public fields of the entity instead of using setter method?

Thanks, Chir

1

1 Answers

3
votes

Weaving introduces some optimizations such as lazy onetoone and manytones and change tracking. The only way these can work is if you use the accessor method on the entity, but if that isn't an option, you can turn them off as needed. See http://eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_changetracking.htm For details on change tracking.