Hello, I am currently facing the task of adding a new database layer based on JPA2 to both a standalone Java application as well as a GWT project that is based on the business logic provided inside this standalone Java application. (Basically GWT acts as the UI-layer by providing service methods for accessing certain methods of the business logic...) The GWT application is running ontop of Tomcat 6 (so no EJBs, ... - But EJBs would not work in the standalone application... so no need to feel pitty ;) Right now the database connectivity is solved by direct SQL commands.
The standalone application has to be runnable without the GWT project as well. Especially the JPA2 connectivity. So here is my approach so far, which I would like to discuss. 1.) Create DB-Entitiy objects for all needed DB-Tables. 2.) Create some kind of static class that holds the EntityManagerFactory for our persistence context. 3.) As soon as any method (inside the business logic of the standalone application or within a GWT service class) needs to create/update/read/ delete data from the database, use the EntityManagerFactory from the static class to obtain a new entitymanager. 4.) Perform the transaction and close the entitymanager at the end of the method. 5.) Objects transferred between the server and the client are simple DTOs. No annotations or anything. The service methods will wrap the objects obtained from the database into the corresponding DTOs. The update process works the other way round. This way both the standalone application as well as the GWT application would work fine, am I right? No problems with parallel sessions, ... or am I overseeing anything. It is kind of the same approach Google Guice suggest by creating a new Entity Manager for every HTTP Request with the help of a ServletFilter. But honestly I can not see the need for dependency injection in my scenario. The only difference is, that my solution does not create an EntityManager automatically with the help of a ServletFilter, but manually through the EntityManagerFactory obtained from the Singleton class. Please share your comments, advices, hints on the proposed approach. ;) Thanks in Advance for your help! Greetings Stefan -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
