*
The moose likes JDBC and the fly likes How to update table with autoincrement column in JSF application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to update table with autoincrement column in JSF application" Watch "How to update table with autoincrement column in JSF application" New topic
Author

How to update table with autoincrement column in JSF application

Wojtek Thomas
Greenhorn

Joined: Nov 30, 2005
Posts: 11
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

Joined: Apr 30, 2003
Posts: 820

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Wojtek Thomas
Greenhorn

Joined: Nov 30, 2005
Posts: 11
Friend od mine adviced me to create second DataProvider binded to the table with ID column omited.

 
wood burning stoves
 
subject: How to update table with autoincrement column in JSF application
 
Similar Threads
How to make a crud jsf with ebj without id filed?
I need help with Hibernate
SQL exception
SQL Error!!
Arul