• 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

How to use EJB QL to query from Dual

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,


As you know in SQL, if a sequence say "seq_one" is defined in a table say "table_one", we can use SELECT SEQ_ONE.NEXTVAL FROM DUAL. We have a system where in currently an Entity bean is used to persist a record (all fields) except primary key in the table. Primary key is handled as a sequence and a trigger is fired for every new record inserted, which would assign NEXTVAL of the primary key. We have a requirement to have it done through the entity bean just like other fields. But the problem is, we still want to use the sequence (primary key is defined as sequence) to determine the next value and assign it as the primary key while creating the Entitybean. I wonder, if this can be achieved using Home Business method, with the help of EJB QL. If so, what should be the EJB QL look like. I tried googling it, but could not find any good information.

If this is not possible, the other option left out with me is to use straight JDBC call.
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could any one look into this post and guide me? Let me know, if the information provided is vague or incomplete, so that I can try to furnish more.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the point is you do not have to "assign it as the primary key while creating the Entitybean". It is done behind the scene when you persist the entity bean.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Precisely. You need to define your key generation strategy in your Entity Bean and the container will take care of the rest. Explicitly using database specific concepts from an Entity Bean doesn't make sense after all - you use an ORM to abstract this sort of stuff.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic