• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to save object's state

 
Navneet Sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

I am fetching business data from Oracle DB and saving it into a business class object. I want to save this object's state so I can use this anywhere in my code. I am thinking to achieve this with Seriailazation or with help of Session (session.setAttribute). Please suggest which will be most optimal and effective approach ? Please also suggest some others approaches if applicable ?

Thanks in advance !!
 
Mahender Parkipandla
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can store it in Java Bean to access through out the application.
Get data from DB and store in Java Bean and store the Java Bean class in session.

You can get the data from session when ever you need.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am thinking to achieve this with Seriailazation or with help of Session (session.setAttribute). Please suggest which will be most optimal and effective approach ?


My suggestion - it depends on how long you need to keep the state around and on if the amount of memory used may be a problem.

I use serialization for objects that have a long useful life that may extend over several user sessions - you will need a mechanism for associating a unique file name with the user.

Sessions require less programming and are fine for objects that don't live past one user session.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic