• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with Primary Key/ Generator class [Hibernate]

 
abhishek roy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have two tables with a one to many relationship. those are company and employees. who share a primary key and a foreign key in the relational database. Now when i try to apply hibernate and put the relationship in the hbm.xml file i feel that the primary key which the company no. is autogenerated. Can there be any solution to this to prevent autogeneration of primary key. I have used generator class on type native. But i want to specify the all the fields and primary key while adding a new record.
Is there any solution. to this

any help is deeply appreciated,

regards,
Abhishek
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a assigned key, e.g. :
 
abhishek roy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot . That solved the problem

regards,
Abhishek
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
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!