aspose file tools
The moose likes Object Relational Mapping and the fly likes Named Queries in Persistence Archive Possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Named Queries in Persistence Archive Possible?" Watch "Named Queries in Persistence Archive Possible?" New topic
Author

Named Queries in Persistence Archive Possible?

sever oon
Ranch Hand

Joined: Feb 08, 2004
Posts: 268
Hi all,

I'm writing an EJB3 application, and everything is going great. Except, I decided to split off the entity beans into a separately deployed jar (a persistence archive) because we have several different components that will make use of just the entity layer (each component consists of a layer of local session beans over the entities).

But when I do that, none of my session beans have access to the named queries defined in annotations on the entities. If I package the session beans and entity beans together, no problem. If I don't, I start getting hibernate MappingExceptions (JBoss uses Hibernate to implement the persistence part of the EJB3 spec).

Named queries can only be annotated on entities, so I can't move those annotations onto the session beans themselves and define them there. So what to do? Does anyone have experience here defining named queries for a persistence archive, and somehow making them visible to other components? They're all using the same persistence unit, btw.
Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
To access a persistence unit and its entities, you need to package and deploy it with the application that uses it. One can package the persistence unit into a separate .jar and then include this .jar with the application.
 
 
subject: Named Queries in Persistence Archive Possible?
 
Threads others viewed
Issue when using 2 entity managers to manage one entity from one database to another
what exactly meant by JPA?
Using Detached Entities in the Web Layer
EJB3 and JPA
Component Diagram and Part 2
developer file tools