-->
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: Please help regarding this master-detail tables
PostPosted: Sat Jun 18, 2005 12:10 am 
Beginner
Beginner

Joined: Wed Aug 25, 2004 10:27 pm
Posts: 21
Location: Indonesia
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.6

Name and version of the database you are using: SQL Server 2000

Hi all,

I have the following parent-child tables :

Table : Orders
=========

OrderID
---------
1


Table : Items
=========

OrderID ProductID Total
--------- ------------ -----
1 11 1
1 12 1
1 13 1

At runtime I create the following class for table Order:

public class Orders
{

private String orderID;
private int total;

public void setOrderID(String orderID)
{
this.orderID = orderID:
}

public String getOrderID()
{
return this.orderID;
}

public void setTotal(int total)
{
this.total = total;
}

public void getTotal()
{
return this.total;
}

}

When Hibernate queries data from table Order, I need to set the field total with the sum of total in table Items.

Is is possible to achieve that automatically using Hibernate with one-to-many relationship ?


Thanks in advance.


Setya


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.