First off, you're using subclassing enhancement which isn't recommended... Please checkout these links[1][2] for more info.
On to your real question... > Our application is a Swing application that displays data fetched directly from the database. Is this application just going to display the data, or will it also update the data? Thanks, Rick [1] http://openjpa.apache.org/entity-enhancement.html [2] http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html On Thu, Jul 22, 2010 at 10:37 AM, Pandel <[email protected]> wrote: > > Our application is a Swing application that displays data fetched directly > from the database. There is a single entity manager and an extended > persistence context. Because we want the GUI to be responsive, all the > transactional database operations are executed into a single separate > worker > thread. We don't use the openjpa.Multithreaded = true option because it > introduces overhead and also because it is susceptible to a deadlock (issue > OPENJPA-1716). > Calling a getter on one entity inside the Event Dispatch Thread, while > other > operations are executed onto the entity manager in the separate worker > thread, will automatically access the BrokerImpl concurrently from the EDT > too. Here is a snippet of a stacktrace confirming this: > > Exception in thread "AWT-EventQueue-0" <openjpa-1.2.1-r752877:753278 fatal > internal error> org.apache.openjpa.util.InternalException: Multiple > concurrent threads attempted to access a single broker. By default brokers > are not thread safe; if you require and/or intend a broker to be accessed > by > more than one thread, set the openjpa.Multithreaded property to true to > override the default behavior. > at org.apache.openjpa.kernel.BrokerImpl.endOperation(BrokerImpl.java:1792) > at org.apache.openjpa.kernel.BrokerImpl.isActive(BrokerImpl.java:1740) > at > > org.apache.openjpa.kernel.StateManagerImpl.beforeRead(StateManagerImpl.java:942) > at > > org.apache.openjpa.kernel.StateManagerImpl.accessingField(StateManagerImpl.java:1477) > at > > org.apache.openjpa.enhance.RedefinitionHelper.accessingField(RedefinitionHelper.java:59) > at org.apache.openjpa.enhance.Tabelle$Pratica$pcsubclass.getClienti(Unknown > Source) > at Modelli.ClienteView.<init>(ClienteView.java:93) > at Modelli.ClienteController.<init>(ClienteController.java:39) > at Modelli.PraticaController.createPraticaView(PraticaController.java:51) > > My question would be: is there proper way to prevent this from happening? > How can I keep executing the time-consuming transactional operations into a > worker thread, and still be able to call a getter onto another entity, in a > thread different than the worker thread, without causing this exception? >
