• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collection that is synchronized with DataBase

 
Ayan Dutta
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can have a updatable resultset ,so that if do any changes in the DB it will be reflected in the DB.
I want to prepare a collection (say map)that is loading data from the DB just for one time (say from a single table).Whenever there is any change in the DB it(the map) will be updated .
Can it be done using JDBC ?
Regards,
Ayan
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our JDBC forum...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ayan,
Not with pure JDBC. Maybe an O/R mapping tool supports it.

I'll move this thread to our Object/Relational Mapping forum to see if anywhere there knows. Sorry to shuffle your question along, but this helps get the best possible answer.
 
Ayan Dutta
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have send this query a long time ago ,can anybody provide any hint on this using Hibernate if this thing can be done ?
Regards,
Ayan Dutta
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not with Hibernate. I can't think of anything that does it out the box. What do you need such close synchronization between the persistent store and the in memory model?
 
Ayan Dutta
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just want to see ,it can be done or not .
Regards,
Ayan
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Databases don't normally push changes out - you have to go get them. Nor does JDBC support such operation.

However, what you probably actually want isn't a live-and-immediate update on the data. It is sufficient that when your java app wants data, it gets the up-to-date data. Having the data pushed to you is less important than ensuring that what you access is not going to be stale.

Just as a side note, if at all possible, avoid having multiple apps update the same set of data. It's very difficult to avoid - or to track down - problems when you don't know where the changes came from. I learned this at great expense when I worked with OS/2 and they'd keep config information splattered over different files that wouldn't stay in sync. Databases and networks will just make the problem even worse.

However, sometimes external changes are unavoidable. I'm pretty sure that even the earliest EJB specs allowed for that. I'm not sure about Hibernate (I think so), but I know that there are a number of features available for JDO, up to and including third-party add-ons like the Tangesol external cache product. By default these options are turned off, since the overhead for checking items before each access is pretty high, but the features are there for those who need them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic