• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use EJB QL to query from Dual

 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
bilbono notry
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!