-->
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: no annotation example code for section 6.4.3 Item/Bid?
PostPosted: Thu Jan 14, 2010 12:52 pm 
Newbie

Joined: Thu Jan 14, 2010 12:33 pm
Posts: 4
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")


Top
 Profile  
 
 Post subject: Re: no annotation example code for section 6.4.3 Item/Bid?
PostPosted: Fri Jan 22, 2010 6:57 am 
Newbie

Joined: Fri Jan 22, 2010 1:23 am
Posts: 3
I was facing similar problems with my code having Bid feature.I hope someone will give some good response our questions.


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.