• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Attempt to modify an identity column

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These exceptions throw with commented setId:

[ August 25, 2008: Message edited by: manu chaox ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try


instead of,

 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by manu chaox:
These exceptions throw with commented setId:



There is no exception shown in your post.
 
manu chaox
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using session.save()?
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try this, to print the actual SQL on the console.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<id name="id" column="ID">
<generator class="identity"/>
</id>
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic