Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Data class instances

 
Efstathios Arethas
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys!

I am almost done with the project , but i have some thoughts about the Data class , lets take this scenario the user starts a server , then the user starts also a standalone client to work with the same file as the server does , so both server and client work with same db file, i want the server and the standalone client to share the same Data object under the same VM , for the time being they don't share it , in my Data class i use lazy initialization like Map<DatabaseLocation,Data> so from the getInstance( DatabaseLocation) method i expect to get the same Data object , but i don't because the objects i get have different hash codes when i use the same db location string, why this happens? I have tried the singleton pattern also but still different hash codes! I just want to have one Data object per db file , in order the locking mechanism to work for all threads , i must say the server locks the records when requested by the net clients but works independently from the standalone client because they don't share the same Data object. Please advise.
 
Roel De Nijs
Sheriff
Posts: 9827
102
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From my instructions:
You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server.

So your scenario will never occur
 
Efstathios Arethas
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:From my instructions:
You may assume that at any moment, at most one program is accessing the database file; therefore your locking system only needs to be concerned with multiple concurrent clients of your server.

So your scenario will never occur


Hello Roel
You have right ! I missed this one!
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic