• 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

get generated key

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic