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