[jboss-dev-forums] [EJB3 Development] - Re: Entity hashCode and equals overriding

fabio valsecchi do-not-reply at jboss.com
Sat Jan 5 11:02:55 EST 2013


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&containerType=14&container=2030]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20130105/e520e290/attachment.html 


More information about the jboss-dev-forums mailing list