This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to represent a sequence in oracle in HQL

 
Venkat dasari
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic