-->
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: Very Urgent : Detached Criteria and Hibernate Association
PostPosted: Wed Jan 18, 2012 3:56 pm 
Newbie

Joined: Wed Jan 18, 2012 2:39 pm
Posts: 1
I am using hibernate 3 annotations to annotate relationship between classes.

I have a class with name Person and below is the content

Class Person
{
Private Contact a;
Private Department b;
private String name;


@OneToOne(fetch=FetchType.LAZY, mappedBy="Person", cascade=CascadeType.ALL)
public Contact getA() {
return a;
}

@OneToOne(fetch=FetchType.LAZY, mappedBy="Person", cascade=CascadeType.ALL)
public Contact getB() {
return b;
}
}

I am using below statements to retrive person details like Contacts and Department which he belongs

DetachedCriteria searchCriteria = DetachedCriteria.forClass(Person.class)
.add(Restrictions.eq("name", "John"))
.addOrder(Order.asc("name"));
getHibernateTemplate().findByCriteria(searchCriteria);

But in this same even when i want only contact details and not Department, it is fetching data from both the table. I need to know how to add a filter or restriction in such a way only contact details are fetched and Department related details are not even queried.


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.