Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help required in problems with Assigned generator class

 
Sripad Kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using assigned generator class. Because I have lot of legacy data. To manage that I started using assigned generator class. What are all the problems I may face with this? How to overcome them? Please help me to get out from this problem.
Thanks,
Kumar.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really don't see what problem you're talking about?

If you decide to use "assigned" generator for your Hibernated domain objects, then Hibernate lets you do all ID assignments for newly created entities. I.e. when you want to create a new persisted Order object, you say "myNewOrder = new Order()" and call the primary key setter, e.g. "myNewOrder.setId(getNextAvailableIdFromSomewhere())".
 
Sripad Kumar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!,
We are migrating our database from SQL Server to Oracle, meanwhile we decided to use hibernate. We cannot add extra id column to the database tables. We must use the existing primary-key as id in our case.

Hibernate supports assigned generator class to support this. But hibernate-reference.pdf document or hibernate in action book says if we use assigned generator we will be in troubles while working with detached objects/Trancient Persistence.

Is there any other generator class which will accomplish my requirement.
Thanks,
Kumar.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. I see. I haven't worked with detached objects in Hibernate yet so I'm afraid I can't be of much help there.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But hibernate-reference.pdf document or hibernate in action book says if we use assigned generator we will be in troubles while working with detached objects/Trancient Persistence.

if you have HiA, at the end of 3.4.3 (page 92), i think they refer to your problem and say they discuss it in chapter 8, section 8.3.1 - legacy schemas and composite keys
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic