Monday, March 5, 2007

How to create primary key using hibernate?

id field in hbm.xml file is used to specify the primary key in database. We also use generator to specify the way primary key is generated to the database. For example

< id name="testId" type="string" >
< column name="testColumn" length="40" / >
< generator class="increment" / >
< /id >

here the primary key field name in database is testColumn and it will autonmatically incremented by one as the generator is specified as increment.


SOURCE : www.referjava.com

2 comments:

REFERJAVA said...

Good Question

Anonymous said...

Good Stuff Here