db4o Developer Community
Developer Community db4o open source object database, native to Java and .NET
Register   |  Login
  Search
  • Forums
  • Documentation
  • Resources
  • Downloads
  • Blogs
  • About
Unanswered Active Topics Forums
Forums > English Forums > db4o User Forum
Db4o and Session
Last Post 28 Nov 2006 06:38 PM by treeder. 4 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
operations_br
New Member
New Member
operations_br

--
27 Nov 2006 07:17 PM  
Suppose that i have a class User, and when someone make the login at my website, i retrieve the whole use object. Since the user already made the login, it is obviously that i want to store this User object in some way that when the user navigates through my site he remains logged.... But, it seems that when i store the user object in a session and retrieve it, the Db4o looses its reference to the real object and treats the user object retrieved from the session as a new user, meaning that if i persist this object, Db4o wont update, but create a new one... How can i solve this problem? Since Db4o team do not recommend to work wit objects internal IDs what is the recommended pattern to develop websites and pass objects between pages?
lypanov
New Member
New Member
lypanov

--
28 Nov 2006 02:09 PM  
Ran into the same problem today. Your question is very enlightening as it saves me the time of actually reproducing this. It was just a hunch previous to seeing your post. Thank you. Here's hoping someone else has a good solution.

I was thinking that activate would do the job maybe but haven't yet had time to try it.
jecho
New Member
New Member
jecho

--
28 Nov 2006 03:28 PM  

As much as I know the internal ID remains the same (i.e. will not change for the object) as long as the database file has not been defragmented. If you defragment the file you should not relay on the old ID (from the time before the defragmentation) and obtain the new ID of the object you use.

You can also save the name of the user instead of its ID in session (or in cookie if you use ASP.NET Forms authentication) and use a query to obtain the user's object from the database.

lypanov
New Member
New Member
lypanov

--
28 Nov 2006 03:37 PM  
ID's (or better, UUID's) would I guess solve this. But this removes some of the type strictness in my program that was hoping to gain by using db4o in the first place.

I was more hoping for a way of reconnecting the object with the database, Hibernate has such functionality.
treeder
New Member
New Member
treeder

--
28 Nov 2006 06:38 PM  

I posted a blog post about this yesterday, the solution presented might help you.

http://db4o-tools.blogspot.com/2006...aging.html

 

You are not authorized to post a reply.
Forums > English Forums > db4o User Forum

Active Forums 4.2
Close
Copyright ©2000-2010 by Versant Corp.
Privacy Policy