aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to represent a sequence in oracle in HQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to represent a sequence in oracle in HQL" Watch "How to represent a sequence in oracle in HQL" New topic
Author

How to represent a sequence in oracle in HQL

Venkat dasari
Ranch Hand

Joined: Nov 12, 2003
Posts: 67
Hi,
I have a table with composite key. In that one field in the composite key must be sequence generated. Is there any way of representing a sequence table in oracle in HQL?? I have a sequence in my oracle database called Concurrent. Now, i would like to know how can i get the value from the Concurrent sequence and map to the part of my composite key.

Please do inform regarding this

thanks in advance..
Venkat Dasari


Regards,<br />Venkat Dasari<br />SCJP 1.4, SCBCD.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You can map a sequence as a key generation strategy like this:

You would use this as your primary key for which ever object you are mapping. Hibernate doesn't give you a way to map this id as part of a composite id. Why? Well I would guess its because there is no valid reason for doing this. Composite ids tend to get used to create a natural key for an entity which doesn't really have one instead of using a synthetic key. The only purpose of a sequence in this context is to generate a synthetic key. If you already have a quarenteed non-null, unique, unchanging value in your composite key, what part do the other members of the key play?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to represent a sequence in oracle in HQL