• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate mapping xml

 
palas das
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we should use "identity" as generator class for id column.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you have defined an identity column in your DDL for the entity you are mapping.
 
saranga rao
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the database has an identity column associated with it, Hibernate can take advantage of the column to indicate when an object hasn�t been added to the database.
 
bren jas
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i have define a column of a table as primary key.
and for that column in mapping file i have put generator "identity"
But when I am going to insert data in that column it is giving exception
"ID does not have default value"

can anybody tell me why it is happening?
 
saranga rao
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

which database you are using......... this will not support for Mysql


regards
saranga
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Actually i have define a column of a table as primary key.
and for that column in mapping file i have put generator "identity"

So you are not actually using an identity column? You will need to define the primary key field as an identity column if you want to use that key generation strategy.


which database you are using......... this will not support for Mysql

MySQL does indeed support identity columns.
[ May 10, 2007: Message edited by: Paul Sturrock ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic