Why do you need to know if the entities are dirty or not?
JPA automatically persists dirty entities.
So:
MyEntity e1 = load(MyEntity.class, id);
e1.setProperty("new value");
//This will be saved when the EntityManager is flushedSo, for new instances, call persist(). For disconnected instances, call merge(). For managed instances, just update them. Luis Fernando Planella Gonzalez Em Quinta-feira 25 Junho 2009, às 14:07:57, Roger escreveu: > On Thursday 25 June 2009 16:27:20 Daryl Stultz wrote: > > On Wed, Jun 24, 2009 at 4:22 PM, Roger <[email protected]> wrote: > > > is there a way > > > through the "enhanced" version to detect which entities have been changed > > > so I > > > don't call persist() for them, > > > > Well, since no one else has replied, I might be able to help. Try this: > > OpenJPAEntityManager openJpaEm = (OpenJPAEntityManager) em; > > assertTrue(openJpaEm.isDirty(entity)); > > > > Is it ok to do that? Shouldn't I be working through the generic Persistence > API rather than "tying" myself to the specific implementation? > > > > > > or do I persist() them all and trust openJpa to > > > only physically persist entities that have changed? > > > > First I assume you mean merge() rather than persist() as persist() is > > something you do with new entities. > > > > I am more of a newbie than I thought then. I thought merge() was something > that you did when you had a "disconnected entity. Are there any good > tutorials > online anywhere for beginners - I find the openjpa manual a bit turgid and > assumes that I know more about things than I actually do > > Regards >
