-
1. Re: How to update a field in CMP Entity Bean
lepekhine Jan 28, 2002 10:06 AM (in response to prakash)You should write CMP EJB with persistant storage equals the desired table. There are many ways to do it but the simpliest is to set getter and setter methods in CMP equals get() and set(). You must also define the proper table name in deployment descriptor. After that table rows will be updated when you use set() method in client program.
-
2. Re: How to update a field in CMP Entity Bean
prakash Jan 29, 2002 5:57 AM (in response to prakash)Hi Lepekhine,
Here is the detailed description of my problem.
I am developing a change password module. In my application once user is validated, the user will have an option to change the password, which allows users to enter newpassword along with old password for confirmation.
Whenever I call EJB from JSP client using the create method it is trying to insert values as new row and causing "DuplicateKey Exception." But I want to update the new password only. I am not sure whether this can be done using CMP Entity Bean.
My JSP client calls the EJB as...
ChangePwd cpwd = homechangepwd.create(ui.getUserId(), npassword);
Please suggest solution to this problem -
3. Re: How to update a field in CMP Entity Bean
lepekhine Jan 29, 2002 6:15 AM (in response to prakash)I suppose userId to be the primary key in password table. When you wrote home.create(...) you insert a new record into the table. If you want update the existing row you must find it and then update. If you got FinderException it means that there is no such row and you can insert the new one. The code may be:
try {
ChangePwd cpwd = homechangepwd.findByPrimaryKey(ui.getUserId());
cpwd.setPassword(npassword);
} catch(javax.ejb.FinderException e) {
homechangepwd.create(ui.getUserId(), npassword);
} -
4. Re: How to update a field in CMP Entity Bean
prakash Jan 30, 2002 4:15 AM (in response to prakash)Hi Lepekhine,
Thanks for the info. Now I am able to change the password. But the problem is it's not getting commited in the database.
Please suggest solution. -
5. Re: How to update a field in CMP Entity Bean
sk4567 Feb 14, 2002 5:54 AM (in response to prakash)hey all,
i am getting the same problem...everythings working fine...no exceptions are being raised...all values are being passed to entity bean ...but database is not getting updated..
i have the assembly descriptor set for container transactions..("required")...please can anyone throw somw light..
regards,
Saurabh.. -
6. Re: How to update a field in CMP Entity Bean
sk4567 Feb 15, 2002 5:55 AM (in response to prakash)hey all,
my problem has been solved...had a stupid bug..
thanx
sk -
7. Re: How to update a field in CMP Entity Bean
jbossuser Feb 18, 2002 9:39 AM (in response to prakash)What code base are you using? I'm seeing the same thing on a recent build from source forge.
-
8. Re: How to update a field in CMP Entity Bean
morten Feb 21, 2002 8:34 AM (in response to prakash)I have a problem, that might relate to the same thing:
The fields of my CMP based EJB becomes null after half an hour. This indicates that the EJB is not really saved but only cached.
I'm using hyperSonics.
Why does my CMP fields become null values?
Morten Andersen
Denmark -
9. Re: How to update a field in CMP Entity Bean
cisbrh Feb 21, 2002 9:21 AM (in response to prakash)For all the ones with the pb of the db not being updated you can try to look at :
http://main.jboss.org/thread.jsp?forum=67&thread=4964&message=370705&q=#370705
benjamin