-->
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.  [ 6 posts ] 
Author Message
 Post subject: Joining 2 existing criterias
PostPosted: Tue Mar 16, 2010 1:07 am 
Newbie

Joined: Sun Mar 14, 2010 10:57 pm
Posts: 5
Hi, Is there a way to join 2 already created criteria as one single criteria?

I have 2 criterias, Criteria A with specific criterions querying through the first table and Criteria B querying through another table.


Top
 Profile  
 
 Post subject: Re: Joining 2 existing criterias
PostPosted: Tue Mar 16, 2010 1:43 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
any relationship between both tables?


Top
 Profile  
 
 Post subject: Re: Joining 2 existing criterias
PostPosted: Tue Mar 16, 2010 8:54 pm 
Newbie

Joined: Sun Mar 14, 2010 10:57 pm
Posts: 5
yes. they have a reference(fk) column between them.


Top
 Profile  
 
 Post subject: Re: Joining 2 existing criterias
PostPosted: Tue Mar 16, 2010 11:01 pm 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
Suppose you have classes like these:
Code:
class Child {
    private Parent parent;
}

class Parent {
...
}

Criteria mainCriteria = session.createCriteria(Child.class);
Criteria otherCriteria = mainCriteria.createCriteria("parent"); //association path


Top
 Profile  
 
 Post subject: Re: Joining 2 existing criterias
PostPosted: Tue Mar 16, 2010 11:37 pm 
Newbie

Joined: Sun Mar 14, 2010 10:57 pm
Posts: 5
I have something like this..
Code:

class Child extends Parent{
    private String applicationId; // which is a FK to transactionId
}

class Parent {

    private String transactionId;

}

so do I need to make an instance of the Parent class within the Child class?
Is there any other way of doing it without changing the structure of the class, lets say defining annotations on one of the fields?..
Also please note that the Child extends the Parent class.



I also have a case wherein..
Code:

class Child extends Child2 {
}

class Child2 {

       private Parent parent;
}

class Parent {
}


I need to query within Child and parent. Will i get the parent attribute instantly from Child through child2?


Thanks for the help.. very much appreciated.


Top
 Profile  
 
 Post subject: Re: Joining 2 existing criterias
PostPosted: Wed Mar 17, 2010 10:25 pm 
Newbie

Joined: Sun Mar 14, 2010 10:57 pm
Posts: 5
up


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.