[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - unable to update entity in collection

u268 do-not-reply at jboss.com
Sun Dec 16 11:26:54 EST 2007


Another odd thing with hibernate:

using the code below I'm unable to update entity data but successfully may add new one to collection :

anonymous wrote : /**
  |      * Writes qualification info into DB
  |      *
  |      * @param qualification object model to be updated
  |      * @return true if successfull
  |      * @throws Exception
  |      */
  |     public boolean saveQualification(UsersAcademicQualifications qualification) throws Exception {
  |         if (qualification != null) {
  | 
  |             usersAcademicQualificationsHome.setInstance(qualification);
  | 
  |             if (qualification.getId() != null && qualification.getId().trim().length() > 0) {
  |                 usersAcademicQualificationsHome.update();
  |             }
  |             else {
  |                 usersAcademicQualificationsHome.persist();
  |             }
  | 
  |             usersAcademicQualificationsHome.getEntityManager().flush();
  | 
  |             //updating related entities
  |             usersAcademicQualificationsHome.setId(qualification.getId());
  |             qualification = usersAcademicQualificationsHome.find();
  | 
  |             //adding new qualification to related Users object
  |             {
  |                 qualification.getUsers().getUsersAcademicQualifications().add(qualification);
  |                 usersFacade.saveUser(qualification.getUsers());
  |             }
  | 
  |             return true;
  |         }
  |         return false;
  |     }	

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4113216#4113216

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4113216



More information about the jboss-user mailing list