• Post Reply Bookmark Topic Watch Topic
  • New Topic

composite-id in Hibernate

 
Ben Zaidi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have a database table Book where the primary key is basically a
composite key, which is like

ID + ISBN

If we use normal ID, we can auto-generate the id through sequence
or some other technique. But if we use the composite id mapping
like

Is there any way to generate the auto-sequence for ID in composite-id also?

Ben
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, no. But I would say if that id is generated and is unique, I would choose that as the Primary Key alone, you can still have the id and other field as a unique key in the database.

composite-id does not have a tag to say that one of its properties uses a sequence table.

Sorry

Mark
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!