aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Changes in Entity Bean are not saved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Changes in Entity Bean are not saved" Watch "Changes in Entity Bean are not saved" New topic
Author

Changes in Entity Bean are not saved

Lena Solomonik
Greenhorn

Joined: Aug 17, 2001
Posts: 5
Hello, everyone!
Here is my problem.
I have a table. When I change data in the table, a method of the session bean is called, which in turn calls 'set' methods of entity bean. When I call 'get' method after that, it displays a new data. But changes are not saved in the table. It means that they are not saved in database.
Has anyone had this promlem before?
My code looks as follows:
Travelcondition tc = travelconditionHomeRef.findByPrimaryKey(data.id);

switch(col) {
case 0:
tc.setDisplayOnReport((String)value);
log("Succeeded: set_tc(case 0): new value: " + tc.getDisplayOnReport());
break;
case 1:
tc.setDistrict1((BigDecimal)value);
break;
case 2:
tc.setCorridor((String)value);
break;
case 3:
tc.setLocationName((String)value);
break;
case 4:
tc.setRestriction((String)value);
break;
case 5:
tc.setComments((String)value);
break;
case 6:
tc.setConditions((String)value);
break;
case 7:
data.update = (Boolean)value;
default:
System.out.println("Invalid value entered");
}//end of switch
Thanks a lot.
Lena
Manjunath Subramanian
Ranch Hand

Joined: Jul 18, 2001
Posts: 236

Hi Lena,
Have you written the update statement in the
ejbStore() method? If you have check, the code properly
'coz this method is called when latest values has to be updated
in the data base.
Hope this helps,
Manjunath
surshan
Greenhorn

Joined: Aug 18, 2001
Posts: 2
Hi Lena, Looks like you are using CMP Type of Entity Bean
I dont see any problem in you assigning the values to the class variables of the bean reference.
The only thing which worries me is that control going inside the switch statement.
If your business doesnt require setting up of each fields..you can as well take the whole object inside the entity bean with a single set method and then assign the values inside the entity bean. i know since you are accssing from local session bean and you r not going to have any remote calls..but in case if in future they try to move to a clustered environment then it might have some issues..this is only a recommendation from my end...
to answer your problems...it shd update your field and if you had specified and mapped all the fields in the rdbms.jar xml file
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changes in Entity Bean are not saved
 
Similar Threads
jtable not displayed
Question from Just Java 2
display a checkbox in a table
Table Selection Lost
JTable date edit problem