JPAContainer - should i use it?


So far most issues are working very well. But i am fighting with containment references related to the SQLContainer. I am not sure whether it was a good decision to use it. Since business applications heavily use complex data models with different kind of references, maybe the JPAContainer can meet my objectives a better way.

Eg my current problem:
I am using a master detail block to visualize master data. For instance the customer records.

A table shows all the records. If a record becomes selected, it will be shown in the detail editor and can be changed there.

The customer item has a lot of attributes, references and four ZERO_TO_MANY-Containment references like the InvoiceAddress. Containment reference means aggregation, which describes the lifecycle of the reference target. The InvoiceAddress will be deleted if the customer was deleted.
The ZERO_TO_MANY-Containment references are also visualized as master detail blocks in the detail editor.

So i have to deal with containment trees. If a customer was selected in the table, i am creating a copy of the bean (which is related with the RowItem), put the copy to the editor. Then changes can be made to the mutable copy. If the editor changes are accepted, the changes will be applied to the original container and all changed containers have to be commited.
To do exactly what i described above, i have to write my own entity and entity manager layer which builds an abstraction above the different containers inside the containment tree. Additionally i have forked the SQLContainer and have created a RVContainer since the SQLContainer does not offer functions that are required.

Now i am not really happy with the solution since i a have forked the SQLContainer and there are some issues that have to be done.

What do you think,
should i use the JPAContainer? Would it solve my problems? Does it support ONE_TO_ONE-, ONE_TO_MANY- Containment references out of the box?

Florian Pirchner


any suggestions are highly welcome.

Thanks, Florian

I guess, the question above can be answered with: Yes, we should use the JPAContainer!

During the last weeks Matti Tahvonen and Jonatan Kronqvist did a really good job implementing JPAContainer 2.0.
Based on the source code of the svn repository i was running some tests against it and the performance is really amazing. Since redVoodo deals with business applications and business data we have to be aware of large tables containing a lot of records.

So i have created a table called SimplePerson and added
records to it. The JPAContainer based on that table was the input datasource of an UI-table.
For normal, nobody will do so, but i thought it might be interesting whether the JPAContainer faces the same problems as redVoodods RVContainer (forked SQLContainer with some special enhancements). But no, scrolling the table from
took only about
2 seconds
. An amazing response time for such a big table.

Than i tested the methods getIdByIndex and indexOfId.

: To lookup the record with index
took about
for first access and
for second. → Pretty good results!

: Does not seem to finish in a usable time.

I guess the JPAContainer is a great component to implement business applications based on vaadin. The performance is great and it seems to be ready for real world scenarios!
Although programmers have to be aware about one issue. The indexOfId-method has to be avoided at all. So you have to be careful specifying your configuration for AbstractSelects (ui-components). But if you run your tests against tables with a lot of records, such settings will be detected really fast!

Now continues the integration of JPAContainer as it’s main container. And i am looking forward to nice business applications using the JPAContainer.

Thanks a lot to Matti and Jonatan,
Florian Pirchner

Hello Florian, I have read and enjoyed your post, I was encouraged by it and I tried to insert into my project JPAContainer 2.0.
Since my application has many readings and a few updates I have used the provider Cached.

Just as the use case you described my application in the table shows some of the information of the business object and then editing the mask show all details, including references ZERO_TO_MANY.

The problem is that with the Cached provider when I open the form I get an LazyLoadingException,
using a Not-Cached provider everything works correctly, but obviously the performance scrolling the table are very low.

For now I used a workaround by setting:

  • provider.setCacheEnabled(false);
  • Then I open the form after editing
  • and re-setting provider.setCacheEnabled(true);
    but I’m not happy with this workaround.

Have you had the same problem? how did you solved?
Thanks for your help

Hi Pietro,

due to customer requests i did not find the time to migrate the opensource project to JPAContainer yet.
But we (me and Hans-Georg) started to write the UI components for it, but without having any dependencies to the JPAContainer, nor using it right now.

But it did some tests. They have been based on the examples of the JPAContainer and showed incredible good results!!! So i am looking forward to find the required time to migrate to the JPAContainer soon.

I am really sorry. But currently i do not have the required experience in optimizing the JPAContainer. All my current knowledge is based on the tests done. So i can not give you any hint about it…

Sorry again…
Best, Florian

Thanks, I appreciate your kindness anyway.
If you were to get news about this issue, please let me know, as will I

no one else knows the answer to the question asked?


Pietro, I have three good solutions for you:

  1. use EclipseLink instead of Hibernate
  2. use EclipseLink instead of Hibernate
  3. use EclipseLink instead of Hibernate


If you really need to go on with Hibernate, have you noticed LazyLoadingDelegate helper in JPAContainer 2 ? HibernateLazyLoadingDelegate tries to workaround with most common Hibernate lazy load issues automatically.


Thanks for your reply.
Well, option 1,2 and even 3 require to me to code changes ;-), I’ll try using HibernateLazyLoadingDelegate
otherwise I’ll try to cange provider.

I’ll keep you and the post update.

I tried with LazyLoadingDelegate,
It works but same time I have an exception on the stacktrace:

2012-04-23 18:30:34,992 [tomcat-http--24]
 ERROR org.hibernate.LazyInitializationException - failed to lazily initialize a collection of role: it.demanio.agenda.domain.Attivita.documenti, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: it.mydomain.myproject.domain.MyObject.myCollection, no session or session was closed
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(
	at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(
	at org.hibernate.collection.AbstractPersistentCollection.initialize(
	at org.hibernate.collection.PersistentSet.iterator(
	at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.ensurePropertyLoaded(
	at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.getRealValue(
	at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.cacheRealValue(
	at com.vaadin.addon.jpacontainer.JPAContainerItem$ItemProperty.<init>(
	at com.vaadin.addon.jpacontainer.JPAContainerItem.getItemProperty(
	at com.vaadin.addon.jpacontainer.JPAContainerItem.getItemProperty(
	at com.vaadin.ui.Form.setItemDataSource(
	at com.vaadin.addon.beanvalidation.BeanValidationForm.setItemDataSource(
	at it.demanio.agenda.admin.AttivitaForm.createAllegatiComponent(
	at it.demanio.agenda.admin.AttivitaForm.init(
	at it.demanio.agenda.admin.AttivitaForm.<init>(
	at it.demanio.agenda.admin.AttivitaList$3.buttonClick(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at com.vaadin.event.ListenerMethod.receiveEvent(
	at com.vaadin.event.EventRouter.fireEvent(
	at com.vaadin.ui.AbstractComponent.fireEvent(
	at com.vaadin.ui.Button.fireClick(
	at com.vaadin.ui.Button.changeVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.catalina.core.StandardWrapperValve.invoke(
	at org.apache.catalina.core.StandardContextValve.invoke(
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
	at org.apache.catalina.core.StandardHostValve.invoke(
	at org.apache.catalina.valves.ErrorReportValve.invoke(
	at org.apache.catalina.valves.AccessLogValve.invoke(
	at org.apache.catalina.core.StandardEngineValve.invoke(
	at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(
	at org.apache.catalina.connector.CoyoteAdapter.service(
	at org.apache.coyote.http11.Http11Processor.process(
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$

Anyone knows why?

Unfortunately I know the error but I have not found the solution also :frowning: