Hi all, can i get some help,
1) I am wondering what the annotation would be for the Item class for the section 6.4.3, where there is a OneToMany relationship between Item and Bid
2) I have a question about the Bid class and lack of itemId property
Question #1
---------------
I see that xml and the alternative annotation style is given for Bid but i only
see the xml version configuration of Item in 6.4.3. Do I need to add
this snippet below to Item so that its annotated correctly.
I added the @OneToMany over bids property
Code:
public class Item {
...
@OneToMany
private Set bids = new HashSet();
public void setBids(Set bids) {this.bids = bids;}
public Set getBids() {return bids;}
public void addBid(Bid bid) {bid.setItem(this);bids.add(bid);}
...
}
Question #2
------------
Bid is described in 6.4.2 as
Code:
public class Bid {
...
@ManyToOne( targetEntity = auction.model.Item.class )
@JoinColumn(name = "ITEM_ID", nullable = false)
private Item item;
...
}
what about the property itemId in Bid?
should bid class have a property like below added to it?
@Column(name = "ITEM_ID")
private Long itemId;
----------------------------------
When I am trying to em.persit(item) I am getting errors like
cannot insert NULL into ("BID"."ITEM_ID")