Results 1 to 3 of 3
  1. #1
    meher211 is offline Member
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Default Negative stock problem !

    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 require almost the same time a product of a quantity x, an audit 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 access?

    There are another solution?

    Thank you in advance for your help.
    Last edited by DarrylBurke; 12-15-2012 at 02:11 PM. Reason: Removed annoying all-bold formatting

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: Negative stock problem !

    Don't format your entire post in bold as that makes it difficult to read. I've removed the bold tags.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,524
    Blog Entries
    7
    Rep Power
    20

    Default Re: Negative stock problem !

    Don't split the two actions (checking the amount of stock and adjusting the amount of stock) over two transactions.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. The Stock Class
    By luckyirish in forum New To Java
    Replies: 9
    Last Post: 07-13-2011, 04:40 AM
  2. Stock exchange program
    By askinne2 in forum New To Java
    Replies: 2
    Last Post: 05-02-2010, 11:25 PM
  3. string to negative int problem
    By pendulum101 in forum New To Java
    Replies: 5
    Last Post: 11-01-2009, 05:47 PM
  4. Stock Quotes
    By BartDR in forum Advanced Java
    Replies: 0
    Last Post: 09-15-2009, 09:15 AM

Posting Permissions

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