Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Igor Drobiazko
I started a discussion in the developers list. Feel free to join. On Tue, Jul 12, 2011 at 10:48 PM, Lenny Primak wrote: > Since I have persistence.xml, it didn't even occur to me that I needed > configure it manually, > and the documentation only shows how to do it for a new programmatic PU. > So

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
Since I have persistence.xml, it didn't even occur to me that I needed configure it manually, and the documentation only shows how to do it for a new programmatic PU. So, without knowing that I needed to do this, it was next to impossible to figure out what's going on here. Also, the relationship

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Igor Drobiazko
On Tue, Jul 12, 2011 at 10:28 PM, Lenny Primak wrote: > Thank you! That finally worked. > Great. > > Definitely not trivial to figure out... > Well, actually the documentation mentions how to configure persistence units programmatically. http://tapestry.apache.org/integrating-with-jpa.html H

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
Thank you! That finally worked. Definitely not trivial to figure out... Here is the code if anybody is interested: - @Contribute(EntityManagerSource.class) public static void configurePUs( final MappedConfiguration configuration, final

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
My PUs are statically defined, and they are both development and production PUs available, but only one is accessed at any one time depending on which app server the app is installed. This is actually only one aspect, as this app does access multiple databases. On Jul 12, 2011, at 4:04 PM, Kalle

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Igor Drobiazko
On Tue, Jul 12, 2011 at 9:53 PM, Lenny Primak wrote: > I've been trying to figure out how to add package name to an existing PU > read from persistence.xml, > can you share some code on how to do that? That would work for me just > fine. > I am unable to figure that out. > Check out this module:

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Kalle Korhonen
On Tue, Jul 12, 2011 at 12:53 PM, Lenny Primak wrote: > About scanning all packages, in my situation there is production and > development databases, > they have exactly the same schema, so in this instance scanning all packages > is the right thing to do, > but I would be very happy with contri

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
I've been trying to figure out how to add package name to an existing PU read from persistence.xml, can you share some code on how to do that? That would work for me just fine. I am unable to figure that out. About scanning all packages, in my situation there is production and development datab

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Igor Drobiazko
On Tue, Jul 12, 2011 at 9:24 PM, Lenny Primak wrote: > Thanks again Igor, > Unfortunately, we have other parts of the app using persistence.xml, > so this isn't a great solution. > I don't really see a way to do this cleanly with this method. > You can still have a persistence.xml file. A Persist

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
Thanks again Igor, Unfortunately, we have other parts of the app using persistence.xml, so this isn't a great solution. I don't really see a way to do this cleanly with this method. May I suggest the following patch: EntityManagerSourceImpl.java, - instead of if(persisten

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Igor Drobiazko
On Tue, Jul 12, 2011 at 9:02 PM, Lenny Primak wrote: > I'm having trouble figuring this out. Can you help me so I can go on a > well deserved vacation? > I wasn't fast enough since your last mail :) Please checkout the "XML-less JPA configuration" section at the following page. http://tapestry.

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
I'm having trouble figuring this out. Can you help me so I can go on a well deserved vacation? BTW your book is fantastic! On Jul 12, 2011, at 2:09 PM, Igor Drobiazko wrote: > Hi Lenny, > > the JpaEntityPackageManager service is invoked if only a single persistence > unit is defined. The reaso

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
Igor, do you mind sending me quick sample on how to do this? Really appreciate it. This is a bit confusing to me. On Jul 12, 2011, at 2:09 PM, Igor Drobiazko wrote: > Hi Lenny, > > > So, you need to contribute a PersistenceUnitConfigurer to the > EntityManagerSource service's configuration. >

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Igor Drobiazko
On Tue, Jul 12, 2011 at 8:20 PM, Lenny Primak wrote: > > > If I may offer a suggestion... > In case of multiple persistence units, perhaps it would be better to scan > the whole app for entities, > rather than scan nothing. This would seem much more appropriate default > behavior, > as it is not a

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
Never mind this, I actually will have multiple different databases that this app accesses in the future, so multiple PUs are here to stay. On Jul 12, 2011, at 2:13 PM, Lenny Primak wrote: > Thanks Igor! > Perhaps I am not doing things the optimal way. > My use case is that I have a production an

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
Thanks again, Igor, I will try this out. If I may offer a suggestion... In case of multiple persistence units, perhaps it would be better to scan the whole app for entities, rather than scan nothing. This would seem much more appropriate default behavior, as it is not at all clear and simple ho

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
Thanks Igor! Perhaps I am not doing things the optimal way. My use case is that I have a production and a development database. I would like to have the same war file for both, and depending on system properties, choose what database to access. I have Persistence Unit for the production and one fo

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
Ok, I've debugged this a bit further. providePagkages() gets called ONLY if there is only one persistence unit in persistence.xml. On the other hand, in the all-important case of multiple persistence units, providePackages() does not get called. Any ideas? Thanks! On Jul 12, 2011, at 1:00 PM, L

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Igor Drobiazko
Hi Lenny, the JpaEntityPackageManager service is invoked if only a single persistence unit is defined. The reasons are: 1) 99% of the apps are using a single persistence unit. In this case, auto-configuring entities from the entities su-package is very useful. 2) if multiple persistence units are

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
I use persistense.xml. I don't think @Contribute(JpaEntityPackageManager.class)public static void providePackages(Configuration configuration) is getting called, hence continuing of my frustrations. Still need help with getting that resolved. Thanks! Here is my persistense.xml: ---

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Igor Drobiazko
Looks like named query is not know in the BillingPUTest persistence unit. How did you define it? On Tue, Jul 12, 2011 at 2:19 PM, Lenny Primak wrote: > I am using Tapestry 5.3 and the JPA module 5.3 > > In my Page class: > > @PersistenceContext(unitName = "BillingPUTest") private EntityManager e

Re: Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
I believe this piece of code in my app module is not getting called: @Contribute(JpaEntityPackageManager.class) public static void providePackages(Configuration configuration) { log.severe("Calling addPackage()"); configuration.add("com.baw.website.entities"); } An

Problems accessing Named Queries in multiple Persistent Units

2011-07-12 Thread Lenny Primak
I am using Tapestry 5.3 and the JPA module 5.3 In my Page class: @PersistenceContext(unitName = "BillingPUTest") private EntityManager em; @SuppressWarnings("unused") @PageAttached private void populate() { // userList = facade.findAll(); // either variant will work th