• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Named Queries in Persistence Archive Possible?

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic