fabio valsecchi [
https://community.jboss.org/people/fabiovalse] created the discussion
"Re: Entity hashCode and equals overriding"
To view the discussion, visit:
https://community.jboss.org/message/787841#787841
--------------------------------------------------------------
This is my Cart Entity class:
-----------------------------------------------------------------
@Entity
@Table(name = "carts")
public class Cart implements Serializable {
private static final long serialVersionUID = 3L;
public Cart() {
super();
}
@Id
private String username;
@ElementCollection
@CollectionTable(name="cartsbooks",
joinColumns=@JoinColumn(name="username"))
@Column(name="quantity")
@MapKeyJoinColumn(name="isbn", referencedColumnName="isbn")
private Map<Book,Integer> articles;
private float bill;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Map<Book,Integer> getArticles() {
return articles;
}
public void setArticles(Map<Book,Integer> articles) {
this.articles = articles;
}
public float getBill() {
return bill;
}
public void setBill(float bill) {
this.bill = bill;
}
}
-----------------------------------------------------------------
As you can see the getArticles() method returns a HashMap<Book, Integer>, so the
subsequent call get(book) should return an Integer value.
Thank you!
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/787841#787841]
Start a new discussion in EJB3 Development at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]