• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to update table with autoincrement column in JSF application

 
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


 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • 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.
 
author & internet detective
Posts: 40169
812
Eclipse IDE VI Editor Java
  • 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.

 
Skool. Stay in. Smartness. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic