-->
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: how to do this query using HQL ?
PostPosted: Thu Apr 17, 2008 1:35 pm 
Newbie

Joined: Mon May 14, 2007 9:58 pm
Posts: 7
Location: Bahia / Brasil
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.3

PostgreSQL

Problem:

supose the follow classes A, B e C:

====================================================
A "has one" B

A "has many" (a collection) of B

B "has many" (a collection) of C

C "has one" int value
====================================================


So, in example we have:

====================================================
public class A {
private B b;
private Collection<B> bColllection;

//... bean methods ...
}

public class B {
private Collection cCollection;

//... bean methods ...
}

public class C {
private int value;

//... bean methods ...
}
====================================================

Well, I need read "all A objects where the sum of all "value" field of all C object in A.b and A.bCollection is not equal to zero (0)"

In other words, I want something like this:

==============================================
FOR ALL "C" IN "A.B.CCOLLECTION":
SUM += SUM( "C".VALOR )
END FOR

FOR ALL "B" IN "A.BCOLLECTION"
FOR ALL "C" IN "B.COLLECTION"
SUM += SUM ( "C".VALOR )
END FOR
END FOR

IF SUM <> 0
RETURN "A"
==============================================

Now, I have a question:

How to do this using HQL to read this "A" objects from database?

Thank you

--
Cristiano Meira Magalhães


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.