-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: LAZY and EAGER behave differently
PostPosted: Fri Jan 12, 2007 9:33 am 
Newbie

Joined: Tue Dec 19, 2006 4:14 am
Posts: 8
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.