| Author |
Attempt to modify an identity column
|
manu chaox
Ranch Hand
Joined: Apr 10, 2006
Posts: 110
|
|
Hi, I generated classes from database via Hibernate. Database ddl: Aaa.hbm.xml: Bussiness logic: Reading a Aaa from database is ok. But save a Aaa into database throw following exception: Could you help me please. [ August 24, 2008: Message edited by: manu chaox ]
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
I believe, you instruct hibernate to generate the id for you, then why are you trying to pass the value for it. That might be the reason. I assume, you are worried about knowing the value hibernate is gonna generate for you. If thats the case, your save method would return the generated key for you to use further. Cheers.
|
 |
manu chaox
Ranch Hand
Joined: Apr 10, 2006
Posts: 110
|
|
These exceptions throw with commented setId: [ August 25, 2008: Message edited by: manu chaox ]
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
Try instead of,
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
Originally posted by manu chaox: These exceptions throw with commented setId:
There is no exception shown in your post.
|
 |
manu chaox
Ranch Hand
Joined: Apr 10, 2006
Posts: 110
|
|
is the same problem(same exception.)
quote : o riginally posted by manu chaox: These exceptions throw with commented setId: There is no exception shown in your post.
Sorry, I thought previous exception(see above). [ August 25, 2008: Message edited by: manu chaox ]
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
|
Are you using session.save()?
|
 |
Ramesh Srinivasan
Ranch Hand
Joined: Aug 17, 2008
Posts: 35
|
|
Originally posted by manu chaox: is the same problem(same exception.) Sorry, I thought previous exception(see above). [ August 25, 2008: Message edited by: manu chaox ]
I believe bad SQL passed for your RDBMS. Check your datasource in your hibernate and configuration. Also check if you are using any db scripts.
|
SCJP 5.0 93%<br /> <br />"We are what we repeatedly do , then excellence is not an action it is an Habit" Aristotle
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
You can try this, to print the actual SQL on the console.
|
 |
Raghu Dg
Greenhorn
Joined: Sep 10, 2011
Posts: 2
|
|
<id name="id" column="ID">
<generator class="identity"/>
</id>
|
 |
 |
|
|
subject: Attempt to modify an identity column
|
|
|