Access/Update via both JPAContainer and EntityManager

Hello,

we use some JPAContainers for tables and detail editors.
Sometimes we do special operations outside the JPAContainer,
for example deleting a db row via EntityManager or insert children in relation tables.

Frequently the JPAContainer and the EntityManager are no longer in sync.

What is the correct way to make sure both use the same dataset,
and don’t use old stale internally cached data?

André

I’ve got exactly the same problem. Did you find anything yet?

Unfortunally not…

If i can put my 2 cents in:

I’m using an interceptor on the hibernate session (the JPA one is useless) and a custom JPAContainer implementation that gets notified by the interceptor when any entity change.

I’ve implemented this to be able to keep in sync multiple containers and handle nested commits (if a container do a commit all other can review it and commit again) but it’s an overkill if you dont need it.

But, if you simply need to modify a single item entity, something like this would be suffice:


MyEntity entity = entiytItem.getEntity();
entity.setMyProperty(value);
item.markAsDirty(); //<-- not in teh current api

If you simply need this you can use my JPAContaine fork:
https://vaadin.com/it/old-forum/-/message_boards/view_message/4349287

Thanks for your JPAContainer fork.

It solved the problem (and also added the IN(…) functionality which I just needed too)

Looks like the JPAContainer is good for quickstart, but as soon as you need more functionality you have a very steep learning curve (Not knowing if it will be possible to solve the problems we have)

Thanks