Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to update table with autoincrement column in JSF application

 
Wojtek Thomas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Sorry for crossposting, but I didn't know how to remove this topic from JSF forum.

In my JSF application I add some data to the table:


as long as the table doesn't contain AutoIncrement column it works fine.

As soon as I add an ID autoincrement column the code stops working and e.getMessage() returns null. I discovered that there is an exception concerning update of the ID column. I tryied to insert row such as: myTableDataProvider.setValue("MYTABLE.ID", null); but it didn't work.

Using simple SQL INSERT query works fine: I just omit ID field and after commiting new row is inserted with automatically generated ID value.

But I don't know how to modify my first code.

Regards,
Wojtek


 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using some ORM mapping like hibernate right? What do the mapping files look like? You usually have to identify "generated" fields and define what ID generator strategy you are using.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wojtek Thomas wrote:Sorry for crossposting, but I didn't know how to remove this topic from JSF forum.

I deleted it for you. For future reference, just post in your thread you'd like it moved and a moderator can do that for you.
 
Wojtek Thomas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friend od mine adviced me to create second DataProvider binded to the table with ID column omited.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic