File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes primary key field Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "primary key field" Watch "primary key field" New topic
Author

primary key field

vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
Our Registration page collects details from the user and insert into database.We are using ejb to insert the row in database.database is oracle.

While inserting a new record in database, for primary key field we are passing dummy value.While insertion trigger will fire ,which internally calls sequence and generate a primary key for that row.

Now the problem is after inserting a row in database, we are not getting primary key field value in ejb from database, which is actually in the database.Rather We are getting a dummy value that we passed.

How to get the actual primary key field value
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
EJB for whatever reason has no support for autogenerated primary keys.
Can't be an oversight as it's been suggested to Sun with every new version and always ignored.

Generate your keys in the ejbCreate in some way and set them yourself.


42
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
i want to get a autogenerated key in ejb once value is inserted in DB.is there any other way???
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
wanting something doesn't make it so.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: primary key field
 
Similar Threads
Auto increment key in Hibernate
Primary Key question
inserting repeated values in primary key field
Hibernate3.5.6 problem with HSQLDB-2.1.0 dialect
getting Primary key when inserting