• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about Data class instances

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic