-->
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: Hibernate annontations and list
PostPosted: Sun Jun 21, 2009 9:42 am 
Newbie

Joined: Sun Jun 21, 2009 9:07 am
Posts: 1
I have the following two classes. I want the order to contain a list with orderlines. My question is how I make a mapping such that I automatically can retrive the orderlines when I get the order object. And visa verca, if I build up a object with order and a list with orderlines, how do I make the mapping such that when I save the order object, I also save the orderline list in that object.

@Entity
@Table (name="supplierorder")
public class SupplierOrder {

@Id
@Column(name = "id")
private int id;

@Column(name = "date")
private Date orderdate;

private List<SupplierOrderLine> orderlines;

--getters and setters
}

@Entity
@Table (name="supplierorderline")
public class SupplierOrderLine implements Serializable{

@Id
@Column(name = "id")
private int id;

@ManyToOne
@JoinColumn(name="fruit_id")
private Fruit fruit;

@ManyToOne
@JoinColumn(name="supplier_id")
private Supplier supplier;

@Column(name = "number")
private Integer number;

@Column(name = "kiloprice")
private Double kiloprice;

...getters and setters
}


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.