• Post Reply Bookmark Topic Watch Topic
  • New Topic

Javaspace increment object issue  RSS feed

 
Robart Taylor
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im currently making a auction program using java and javaspace. When a new object is created I want it to increment by 1 automatically for the id for the object. Also I want to be able to get the id and set for the starting point for the next user even if the program has closed. Currently it increments but only from 1 to 2, but I think this is because when I try to get the last id written in the space it finds it but perhaps there is multiple ids written in the space and it has choosen the first one, but i'm not certain about this.

Here's my method for getting the latest id from the space and putting it in a local variable called numberOfLots. Apologies as my code is very messy at the moment as I have been trying to fix this for hours, with no luck. Any help would be greatly appreciated, thanks.

Here's my add method:


Here's my object class:




 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robart Taylor wrote:Im currently making a auction program using java and javaspace. When a new object is created I want it to increment by 1 automatically for the id for the object. Also I want to be able to get the id and set for the starting point for the next user even if the program has closed...

Do you mean this? Because that would strike me as a very specialized question, so it might be better if we moved it to one of our other forums. I'm just not sure which one.

However, assuming that you are indeed writing this for a JavaSpaces environment, the requirement seems relatively straightforward:
  • Get a "next ID" from the database.
  • Use it to create a "new object".
  • and I suspect you could test the first part in isolation to make sure it works before you write code for the second.

    I've never used JavaSpace (or Spaces) though, so I don't know if there are any other "wrinkles" to know about.

    I'll leave your query here for a while, in case some other mod knows where to put it. If it's still here when I come back, I'll try to find a more appropriate place.

    Winston
     
    Campbell Ritchie
    Marshal
    Posts: 56530
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    And welcome to the Ranch
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!