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.  [ 2 posts ] 
Author Message
 Post subject: Need help with HQL query
PostPosted: Sun Sep 30, 2007 9:36 am 
Beginner
Beginner

Joined: Wed Jul 25, 2007 6:32 am
Posts: 22
I have a Category domain object.

In my categories table I added an extra column item_count that is updated by a trigger.

I have added a new CategorySummary object that contains the Category with the item_count.

class CategorySummary {
private Category category;
private int nrOfItems;

public CategorySummary(Category cat, int nrOfItems) {
....
...
}
}

I want to build and fill this object with HQL, but how do I do this?
The Category object doesn't know anything about the item_count column, because this is not mapped.

And I don't want my Category object to be polluted with item_count.

Can somebody help me with this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 01, 2007 4:50 am 
Newbie

Joined: Tue Nov 28, 2006 4:34 am
Posts: 5
You can map class inheritance.
For example:
Code:
<hibernate-mapping>
    <class name="Category" table="category">
        ...
        <joined-subclass name="CategorySummary" table="category_summary">
            ...
            <property name="nrOfItems" column="nrofitems" type="long"/>
        </joined-subclass>
    </class>
</hibernate-mapping>


AI


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