-->
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: What's the correct way of writing HQL for resulttransformer?
PostPosted: Tue Sep 11, 2007 5:05 pm 
Newbie

Joined: Thu Jul 05, 2007 4:58 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
Hibernate 3.2.5

Name and version of the database you are using:
MySQL, version: 5.0.45-community-nt

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="test">
   <class name="Test">
      <id name="ID" type="long" access="field">
         <generator class="identity" />
      </id>

      <property name="category" type="int" access="property"
         not-null="true" />

      <component name="c1" class="Component" lazy="false">
         <property name="field1" type="long" access="property"
            column="c1_field1" not-null="true" />
      </component>

      <component name="c2" class="Component" lazy="false">
         <property name="field1" type="long" access="property"
            column="c2_field1" not-null="true" />
      </component>
   </class>
</hibernate-mapping>


What is the correct HQL to allow ResultTranformer to create an entity if I need to aggregate the value in field1 and field2?

I've tried
Code:
SELECT  t.ID as ID, t.category as category, sum(t.c1.field1) as t.c1.field1, sum(t.c2.field1) as t.c2.field1
FROM Test as t
GROUP BY t.category


and

Code:
SELECT  t.ID as ID, t.category as category, sum(t.c1.field1) as c1.field1, sum(t.c2.field1) as c2.field1
FROM Test as t
GROUP BY t.category


but none of it works, any idea how to get around this?


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.