• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Named Queries in Persistence Archive Possible?

 
sever oon
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic