Ok Christian, I see what you mean. Sorry but we were actually doing something else. Our booking object has lots of attributes.
The following works:
Code:
Booking booking = dao.get(id);
booking.setSomething("sdf");
The following does not work:Code:
@RolesAllowed({"Sales"})
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
private void updateBooking(Booking newbooking){
BookingDAO dao = new BookingDAO();
Booking oldbooking = null;
try{
oldbooking = dao.get(id);
}
catch (HibernateException e){e.printstacktrace(); return;}
if (oldbooking != null){
. . .
//Do some comparision work, and create some audit
oldbooking = newbooking; //This does not work.
}
}
How do I update all the attributes without having to explicitly set each attribute? When setting oldbooking = newbooking does not update the changes. Is this when we have to use merge() or there is another way to do this?