There is merit to both sides of this argument, but I believe there are
cases when it's not just as easy as just taking the persistence unit
out of the persistence.xml file. For instance, if you want Seam or
Spring to bootstrap the persistence unit instead of the Java EE
container, you are in a bit of a fix, especially if you plan to use
the Java SE standard way of loading the persistence unit (you can
obviously go around it like Spring does and load a file with a
different name). Also, what you gain by convention (loading all
persistence units in persistence.xml) you lose in build complexity.
For instance, Hibernate Tools allows you to have multiple persistence
units defined in persistence.xml which you can use for testing
queries, but then you have to extract those in your build logic before
deploying. Definitely worth doing for a production build, but not
something to worry about early on in development.
All I'm saying is that I can anticipate plenty of scenarios where I
will need to disable this automatic loading of persistence units (or
selective loading) and right now, I don't see a way to do it in JBoss
AS 5. I'm willing to say that the default behavior is what we want,
but I strongly believe that there has to be some control over this
mechanism.
-Dan
On Mon, Dec 1, 2008 at 8:22 PM, Gavin King <gavin.king(a)gmail.com> wrote:
If you dont want a PC in that deployment, dont put the
persistence.XML file
in the ear. I dont get the problem.
Sent from my iPhone
On Dec 1, 2008, at 4:22 PM, "Dan Allen" <dan.j.allen(a)gmail.com> wrote:
> One of the changes in JBoss AS 5 that comes as a surprise for many
> Seam developers/users familiar with the behavior of JBoss AS 4 is the
> automatic loading of persistence units from /META-INF/persistence.xml.
> (As expected, we had to change several of the Seam examples to
> accommodate this change). This is one of those configuration by
> exception features in Java EE 5, with one significant exception. While
> the container will locate the /META-INF/persistence.xml file on its
> own, a container that goes by the book will only deploy the
> persistence unit if a resource reference is declared in the descriptor
> file (web.xml or ejb-jar.xml). JBoss AS does not wait for this signal.
>
> In my opinion, there is a problem with the JBoss AS approach. What if
> you have persistence units that you don't want to deploy? One use case
> is that you have persistence units for different environments and a
> configuration file can toggle between them. Another use case is that
> you have another library, such as Spring or Seam, which bootstraps the
> persistence unit instead. Sure, you could rename the file, but then
> you break all the IDE behavior that expects the file to be named
> persistence.xml. Personally, I think there should be some way to
> disable the behavior in JBoss AS and make it look for the persistence
> unit references. I agree to keep the automatic loading as the default,
> but it is pretty inconvenient not to be able to disable it.
>
> Anyone else agree? Disagree? Why?
>
> -Dan
>
> --
> Dan Allen
> Software consultant | Author of Seam in Action
>
>
http://mojavelinux.com
>
http://mojavelinux.com/seaminaction
>
> NOTE: While I make a strong effort to keep up with my email on a daily
> basis, personal or other work matters can sometimes keep me away
> from my email. If you contact me, but don't hear back for more than a
> week,
> it is very likely that I am excessively backlogged or the message was
> caught in the spam filters. Please don't hesitate to resend a message if
> you feel that it did not reach my attention.
> _______________________________________________
> seam-dev mailing list
> seam-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/seam-dev
--
Dan Allen
Software consultant | Author of Seam in Action
http://mojavelinux.com
http://mojavelinux.com/seaminaction
NOTE: While I make a strong effort to keep up with my email on a daily
basis, personal or other work matters can sometimes keep me away
from my email. If you contact me, but don't hear back for more than a week,
it is very likely that I am excessively backlogged or the message was
caught in the spam filters. Please don't hesitate to resend a message if
you feel that it did not reach my attention.