Handling autogenerated field in CMP Bean
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   VenkataReddy_Vajrala
Posted On:   Monday, January 28, 2002 07:35 PM

Hi, I need your expert help in writing a simple CMP entity bean, with one field of the primary key being autogenerated at database level. I created a database table in DB2 with three fields, userid varchar(30) not null, insert_time timestamp not null, amount decimal(7,2). Here the first 2 fields are primary key. The default value for insert_time is "current timestamp". i.e., the database itself will insert the value when a record is inserted. Now, my question is, how do we handle this in CMP bean? How to generate hashcode? How to write the PK class? How do we code ejbCreate() method in this situation? Please donot suggest me to insert timestamp from java code. Can anybody give sample co   More>>

Hi,

I need your expert help in writing a simple CMP entity bean, with one field of the primary key being autogenerated at database level.

I created a database table in DB2 with three fields, userid varchar(30) not null, insert_time timestamp not null, amount decimal(7,2). Here the first 2 fields are primary key. The default value for insert_time is "current timestamp". i.e., the database itself will insert the value when a record is inserted.

Now, my question is, how do we handle this in CMP bean? How to generate hashcode? How to write the PK class? How do we code ejbCreate() method in this situation?


Please donot suggest me to insert timestamp from java code.
Can anybody give sample code for this kind of bean?

Thanks in advance.


Venkat.

   <<Less

Re: Handling autogenerated field in CMP Bean

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, January 29, 2002 01:49 AM

Hi,

Since you want to have the Database handling the automatic insertion of the timestamp, you have to build a BMP Entity EJB.
About | Sitemap | Contact