wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Primary Key generation in CMP EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Primary Key generation in CMP EJB" Watch "Primary Key generation in CMP EJB" New topic
Author

Primary Key generation in CMP EJB

Mohnish Saini
Greenhorn

Joined: Jan 04, 2009
Posts: 24
Hello Friends

I need to implement primarykey generation in CMP EJB. That primary key should be of string type.

I have already implemented the primary key generation using java.lang.Integer and java.lang.Long.
But i need to implement using java.lang.String.

<prim-key-class>java.lang.String</prim-key-class>

Please guide me.

Thanks
Mohnish


Mohnish
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Mohnish Saini wrote:I need to implement primarykey generation in CMP EJB. That primary key should be of string type.

Why can't you use Integer? Sequences are pretty standard for autogenerated keys.


[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
Mohnish Saini
Greenhorn

Joined: Jan 04, 2009
Posts: 24
I need a string because if I used Integer or Long in the java code, its max value is far less that the corresponding PK column which is Number(38) in the database. And it will give me Numeric Overflow exception.
 
Consider Paul's rocket mass heater.
 
subject: Primary Key generation in CMP EJB
 
Similar Threads
What is use of separate Primary Key Class in Entity Bean?
how can i specify composite primary key in CMP
findByPrimaryKey() returns null
EJB CMP Primary Key problem
ejbcreate return type