• 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

get generated key

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again!
The EntityManager.persist(EntityBean) method doesn't return the generated Id value by the Database...how can i obtain it?

public void create(Tbcustomer tbcustomer) {
em.persist(tbcustomer);
}

I'll try to implements a query or use annotations like @GeneratedValue...
Somebody can help me?
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sets the value (or values) in the object you passed it.

 
riccardo alfrilli
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tnx for reply!unfortuntely i have an exception,here is my code:


Maybe the @GeneratedValue annotation is wrong(I try also @GeneratedValue(strategy=TABLE),@GeneratedValue(strategy=IDENTITY))
 
riccardo alfrilli
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok,now it's work...I have to set the id(that was an Integer) with initial value of null,not 0!
 
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
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