Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpSessionBindingListener database synchronization confusion

 
Peter Piddle
Greenhorn
Posts: 26
IntelliJ IDE jQuery Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am reading Head First JSP and Servlets and preparing for the exam. It says in topic of HttpSessionBindingListener, that its valueBound() and valueUnBound() can be used when we need to synchronize with the database. I am not aware much about entities with respect to databases. But that is what i get that let say we can make Dog class an Entity and make it implement HttpSessionBindingListener. But still i am unable to understand when we say when it is added to session and it is removed, how valueBound() and valueUnBound() can help synchonize with the database. Are these methods where we will be doing database CRUD operations?
Thanks,
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2405
93
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,

Did you read the explanation in chapter 5 on page 183?

When to synchronize your objects with the database is always a question of web-design. Do you want to update every change to the database or do you want postpone and update a batch of changes.

Are these methods where we will be doing database CRUD operations?

You could do a read in the valueBound() and an update in the valueUnBound() method as an example.

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic