You are creating a new entity manager each time you retrieve an entity
manager, hence you will never have a transaction. Use my sample code and it
will work.
> protected EntityManager getEntityManager() {
> return emf.createEntityManager(); <----- always creating a new
entity manager
> }
Chris
-----Original Message-----
From: gilbertoca [mailto:[email protected]]
Sent: Saturday, 15 May 2010 12:03 AM
To: [email protected]
Subject: Re: InvalidStateException
Rick Curtis wrote:
>
> The message means that you don't have an active transaction to commit....
> :-) Is it possible that your getEntityManager() method call isn't
> returning
> the same em?
>
>
This one is my general apache click page[1] which my regular page classes
extends (like the LegalEntityPage ):
> public class BorderPage extends Page {
>
> /** The root menu. */
> protected Menu rootMenu = Menu.getRootMenu();
> //@PersistenceContext protected EntityManager em;
> protected EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("parkPU");
>
> public BorderPage() {
> addModel("title", "Main Page");
> }
>
> /**
> * Returns the name of the border template:
> <tt>"/border-template.htm"</tt>
> *
> * @see Page#getTemplate()
> */
> public String getTemplate() {
> return "/border-template.htm";
> }
>
> protected EntityManager getEntityManager() {
> return emf.createEntityManager();
> }
> }
>
Is there anything wrong with this approach?
Regards,
Gilberto
[1]http://click.apache.org/docs/click-api/org/apache/click/Page.html
--
View this message in context:
http://openjpa.208410.n2.nabble.com/InvalidStateException-tp210537p5051070.h
tml
Sent from the OpenJPA Users mailing list archive at Nabble.com.