users@glassfish.java.net

Re: Unable to make Java2DB work.

From: <glassfish_at_javadesktop.org>
Date: Tue, 17 Jun 2008 06:26:28 PDT

Hello Notivago,

I think there is some confusion. The tables get created when the EntityManager is first created, as that is when the persistence.xml gets loaded and all the information is available to determine what needs to be created and/or dropped. In a container, it has nothing to do with EJBs, it just happens that this is usually where EMs are injected to and used from. You can

In Java SE, this point is more apparent, as you have to explicitly create the EntityManager. In a container environment such as glassfish, things are more difficult to determine because the process is hidden by injection. Glassfish though will only create the EntityManager for your application if it is used. That means you can define as many as you want, but the container will not dedicate resources to them until they are actually used. This has nothing to do with EJBs; it just happens that this is usually where EMs are injected to and used from. You can access the EM from anywhere in your application using a lookup, which will cause it and the tables to be created.

Hope this helps explain what you are seeing.

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

http://forums.java.net/jive/thread.jspa?messageID=280703