-->
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.  [ 3 posts ] 
Author Message
 Post subject: Is it possible to have Hibernate set a calculated property?
PostPosted: Mon Nov 28, 2005 3:33 pm 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

Mapping documents: Sett.hbm.xml, Item.hbm.xml, SettItem.hbm.xml

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hello, i have these two classes related in a many-to-many relationship. Sett has many Item and and Item is part of many Sett. This relationshipe is performed byt the table/class SettItem. I need to have this table set as a different class because it has the quantity of Item included in each Sett.

The thing is, Item has the property "length" and the sum of the lengths of all the Items adds up to be the "lenght" of the Sett.

What i'm looking to have is Hibernate sum the lenghts of the Items automatically and store in the length property of the Sett.

Is that possible? How can i go about doing that?

Thanks a lot.

Eduardo

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 8:25 am 
Regular
Regular

Joined: Thu Oct 27, 2005 8:06 am
Posts: 55
Location: München, Germany
As long as you can express your calculation in SQL, you can use the formula parameter, resulting in a computed property. Your problem appears as if SQL would easily compute the sum you want.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 1:29 pm 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
Yes, sir! An SQL statement can calculate what i want. From what you're saying, that gives me the possibility of doing what i need...

So i'll look for formula parameter...

Thanks a lot

Eduardo

_________________
Eduardo Mylonas


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