cancel
Showing results for 
Search instead for 
Did you mean: 

How update with EJB

Former Member
0 Kudos

Hi all,

is it possible to update with EJB CMP?? If yes... how?

Thanks,

Vito

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Vito,

Why not, we can do that. Please refer some of the awesome links as i am listing below,

Concepts of CMP:

http://www.caucho.com/resin-3.0/cmp/tutorial/index.xtp

http://java.sun.com/products/jdo/JDOCMPFAQ.html

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7d5db590-0201-0010-dd93-9ec...

Some examples and source code :

http://java.sun.com/j2ee/sdk_1.3/1.3_01/techdocs/release/CMP-RI.html

http://java.sun.com/developer/technicalArticles/ebeans/EJB20CMP/index.html

I hope these will be good enough clear your doubts, if feel necessary reply back.

Regards,

Guru.

Former Member
0 Kudos

Hi Guru,

I just need a simple example of update.

Thanks,

Vito

former_member182372
Active Contributor
0 Kudos

Hi Vito,

In case you are running CMP entity bean, update is done by generated persistency layer and you can perform it just be setting persistent properties (set...() methods) mapped to database table fileds.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Sorry Maksim,

for example, if I have a record in the table that has a primary key N, if I want to update this record with another one with the same value for primary key.....

...in this case I must generate the related entity bean (persistency layer) and use the set methods. Is this right? The record will be updated? <u>Is it the same like I write a record?</u> I don't worry if the record is present in the table(??)

Do you confirm? Thanks,

Vito

former_member182372
Active Contributor
0 Kudos

Hi Vito,

Are you familiar with enitiy beanse? First you have to get reference to home interface (through JNDI), call one of find methods (or create for enitity creation), get reference to component interface of entity bean (or collection of it if it is multiple entities finder), and afterwards call one of setter ot getter(update on DB level is done implicitly).

BTW, primary key MUST be unique.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Maksim,

it's all clear. I just desired a confirm, it is like I thinked.

Thanks,

Vito