Insert new Entity with JPAContainer -> all other items get update too

Im not sure if this is a bug in JPAContainer. Let me describe following situation:

When adding an entity into JPAContainer like this…


V68rgvue entity = new V68rgvue();
entity.setGvue_gvob_vog_id(1234);
container.addEntity(entity);
container.commit();

…everything works as expected. Im getting one Insert-Statement and entity get committed into database.

But if one or more existing entity-objects are read from container before adding an entity…


Iterator<?> iter = container.getItemIds().iterator();
while (iter.hasNext()) {
   Object key = iter.next();
   V68rgvue entityTmp = container.getItem(key).getEntity();
   System.out.println(entityTmp.getGvue_gvob_vog_id());
}

…every single fetched entity is beeing updated even if nothing was changed within these entities. How can I avoid that? Is this a bug?

JPAContainer is initialized like this:


EntityContainer<V68rgvue> container = new JPAContainer<V68rgvue>(V68rgvue.class);
EntityProvider<V68rgvue> provider = new CachingBatchableLocalEntityProvider<V68rgvue>(V68rgvue.class, entityManager);
provider.setEntitiesDetached(false);
container.setEntityProvider(provider);
container.setWriteThrough(false);

Hi,

This sounds like an issue in catchable entity provider. Are you using the JPAContainer 2.0.0-RC1 or still the older one? If you can still reproduce this with the latest version, please add a ticket to dev.vaadin.com. A reduced test case would be nice too, but based on you description that shouldn’t be too hard to create.

cheers,
matti

I think you’re right matti. I forgot to mention that I’m using OpenJPA 1.0. Tested a lot with by switching cache on/off from EntityProvider (Mutable/Batchable) in combination with persistence cache settings → OpenJPA. So using OpenJPA 1.0 with JPAContainer Addon is not really a good performer. Performance with EclipselLink/Hibernate or OpenJPA 2.x is waaaayy better. Too bad that I don’t have much time right now to give detailed feedback.