Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changes in Entity Bean are not saved

 
Lena Solomonik
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic