• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate smart enough to avoid FK issues?

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys :

Is Hibernate smart enough that, to insert "objects" in such an order
that the underlying database doesnt throw foreign key errors ?

Im using the hibernate reverse engineering tool that does
all the object creation / hibernate code generation for you, I assume that my hibernate code will be ideal.

-j
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if the "id" field is a primary key, which
is autoincremented... Does hibernate handle that as well transparently (i.e. can you just make an object, and not set its id field, and insert it ) ?

thanks

jay
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's handled as well. You need to set the id generator in the mapping file. See the Hibernate documentation section 5.1.4.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic