Results 1 to 1 of 1

Thread: Negative stock problem ( e-commerce )

  1. #1
    Join Date
    Dec 2012
    Posts
    1

    Default Negative stock problem ( e-commerce )

    Hello,

    I am trying to conceive it a website selling books online with architecture Struts2-Spring-JPA / Hibernate.

    I confronted the problem of negative stock .. I explain:

    When two customers order almost the same time a product of a quantity x, an treatment is triggered to check if the stock available is greater than or equal to the amount requested. If two control the quantity x (and possibly purchase) happen at the same moment, it is obvious that one of the clients will exhaust the quantity x before the other, which leads to the problem of negative stock for the second customer.

    So I thought to force the application to force the existence of a single instance of every book at a given time for access to its stock available at time t. (Mutual exclusion)

    Suffice it to add the attribute in the declaration of singleton bean Action (Class business processing defined in applicationContext.xml) with additional treatment in the method for pool (Mutualize) access?

    There are another solution?

    Thank you in advance for your help.
    Last edited by meher211; Dec 15th, 2012 at 12:51 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •