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

fabio valsecchi do-not-reply at jboss.com
Sat Jan 5 12:03:22 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/787911#787911

--------------------------------------------------------------
The cart variable is inside the CartBean:
-----------------------------------------------------------------------
@Stateful
@Remote(ICart.class)
public class CartBean implements ICart {
@PersistenceContext(unitName = "JPABOOK", type=PersistenceContextType.EXTENDED)
    EntityManager entityManager;
private Cart cart = null;

public CartBean() {}

    @Override
public void create(String username) {
cart = entityManager.find(Cart.class, username);

if (cart == null) {
cart = new Cart();
cart.setUsername(username);
cart.setBill(0);
entityManager.persist(cart);
        }
    }
    @Override
public void addArticle(Book book, Integer quantity) {
              Integer currentQuantity = cart.getArticles().get(book);

              System.out.println(currentQuantity);

if (currentQuantity == null) {
                  currentQuantity = 0;
        }
        currentQuantity += quantity;
cart.getArticles().put(book, currentQuantity);
    }
-----------------------------------------------------------------------

The cart it could be empty or containg some entries.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/787911#787911]

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/fcf1c69f/attachment.html 


More information about the jboss-dev-forums mailing list