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.
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?