The McpConference has many McpCallLeg. The calls property is defined in McpConference this way:
Code:
@OneToMany(mappedBy="conference", cascade={CascadeType.ALL}, fetch = FetchType.EAGER )
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@org.hibernate.annotations.MapKey(columns=@Column(name="legId"))
private Map<Long, McpCallLeg> calls = new HashMap<Long, McpCallLeg>();
The following code moves a call from one conference to another conference.
Code:
@Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
public void moveCall(String command) {
String[] args = command.split( " " ) ;
long callid = Long.valueOf( args[1] ) ;
long confid = Long.valueOf( args[2] ) ;
McpCallLeg call = confDao.findCall(callid) ;
McpConference originalConf = call.getConference() ;
originalConf.removeCallLeg( call ) ;
call.setConference( conf ) ;
conf.addCallLeg( call ) ;
}
But I found that the call is removed from the database.
But if I chage the 'calls' proprty to use "LAZY" load, the above mthod executed correctly, the call is moved to the another conference and persist in the database correctly.
Why does Hibernate behave this way?
THis is J2SE applicatoin, JDK 1.5, Hibernate 3.2.1 and Springframework 2.0.1
Thanks