aspose file tools
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 Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31551
    
184

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.


[OCA 8 book] [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.
 
 
subject: Primary Key generation in CMP EJB