users@glassfish.java.net

Re: Using persistence from a library

From: <glassfish_at_javadesktop.org>
Date: Sun, 11 Nov 2007 19:05:06 PST

I also see these NetBeans warning in my projects. It's safe to just ignore it if you know what you are doing.

To reuse the entity library in web and desktop apps, you will need to consider the difference of tx behavior. The web app can use JTA while a swing app can only use RESOURCE_LOCAL transaction type. This means you need to abstract out at least the tx demarcation part.

In JavaSE environment, you also need to list all entity classes in persistence.xml. In JavaEE environment, they can be automatically detected.

In webapp's persistence.xml, a datasource is used, and in desktop app, you specify jdbc connection properties. You can tweak the persistence.xml when deploying (in a general term) the entity library to your target applications.

Please see Java Persistence API (jcp.org JSR 220) for more details. I believe there is a chapter for entities in Java SE environment.

-cheng
[Message sent by forum member 'cf126330' (cf126330)]

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