-->
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.  [ 4 posts ] 
Author Message
 Post subject: Setting lazy For One-to-One relation suing Configuration Obj
PostPosted: Tue Oct 05, 2010 9:55 am 
Beginner
Beginner

Joined: Mon Mar 02, 2009 3:36 pm
Posts: 25
I can set one to one relation from hbm file using constrained="true" lazy="proxy" but the same thing i am trying to do from configuration Object using :
Code:
Configuration cfg = new Configuration().configure();
      Iterator<PersistentClass> it = cfg.getClassMappings();
      while (it.hasNext()) {
         PersistentClass persistentClass = (PersistentClass) it.next();
         Iterator<Property> it1 = persistentClass.getPropertyIterator();
         while (it1.hasNext()) {
            Property property = (Property) it1.next();
            System.out.println(property.getName()+" *************** ");
            if(property.getValue() instanceof OneToOne){
               OneToOne oneToOne = (OneToOne) property.getValue();
               oneToOne.setConstrained(true);
               oneToOne.setFetchMode(FetchMode.SELECT);
               oneToOne.setLazy(true);
                   }
                         }
}

But i am to able to set it lazy . Although it breaks the Join , i mean to say, when i am using above code snippet hibernate fires a second select query to find the associated one-to-one entity. I want to change this immediate second select query to Object Navigation query(i.e set lazy).

Any view ? any idea ?

Thanks,
Ganesh


Top
 Profile  
 
 Post subject: Re: Setting lazy For One-to-One relation suing Configuration Obj
PostPosted: Wed Oct 06, 2010 6:01 am 
Newbie

Joined: Tue Feb 02, 2010 10:37 am
Posts: 13
One to one associations cannot be lazy loaded.


Top
 Profile  
 
 Post subject: Re: Setting lazy For One-to-One relation suing Configuration Obj
PostPosted: Wed Oct 06, 2010 11:02 am 
Beginner
Beginner

Joined: Mon Mar 02, 2009 3:36 pm
Posts: 25
one-to-one relation can be loaded lazily by putting
Code:
constraint="true" fetch="select" lazy="proxy"
in the configuration file for one-to-one property.


Top
 Profile  
 
 Post subject: Re: Setting lazy For One-to-One relation suing Configuration Obj
PostPosted: Thu Oct 07, 2010 2:46 am 
Newbie

Joined: Tue Feb 02, 2010 10:37 am
Posts: 13
Following post explains the limitation
viewtopic.php?p=2380205


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

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.