-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate session size and shared cache for readonly objects
PostPosted: Tue Jun 21, 2005 1:03 pm 
Newbie

Joined: Tue Jun 21, 2005 12:55 pm
Posts: 3
Can i have only ONE instance of an object shared between sessions and may be even cached in second level cahe??????

I need it because i load many many objects as a reference data and need them in memory for performance improvement. If an every session has a copy of read-only object it is a waste of memory. I do not need to navigate from reference data to changeable objects so there is no inconsistancy on get().

thnx in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 1:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is better to handle reference data as a UserType rather than an entity association.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 1:43 pm 
Newbie

Joined: Tue Jun 21, 2005 12:55 pm
Posts: 3
gavin wrote:
It is better to handle reference data as a UserType rather than an entity association.


what if i have many differenent read-only classes (reference data) and associations between them that i would like to be able to navigate?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 1:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Handling the *association* as a (parametrized) UserType does not mean that the actual associatted instances can't be instances of a mapped entity class.


(OTOH, you could also try using Interceptor.getEntity().)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 2:17 pm 
Newbie

Joined: Tue Jun 21, 2005 12:55 pm
Posts: 3
gavin wrote:
Handling the *association* as a (parametrized) UserType does not mean that the actual associatted instances can't be instances of a mapped entity class.



(OTOH, you could also try using Interceptor.getEntity().)


let me create an example:

class1 1->* class2 1->* class3

class2 and 3 are read-only

class1 is read-write

how can i navigate from class2 to class3 having only ONE instances of both?

i can create usertype for class2 so that class1 sees it but what is with navigation to class3?


i have found only one usage of interceptor.getEntity in sources if getEntity returns null. Will it work? Will session not duplicate object after getting it from interseptor.getEntity?

public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException {
// todo : should this get moved to PersistentContext?
// logically, is PersistentContext the "thing" to which an interceptor gets attached?
final Object result = persistenceContext.getEntity(key);
if ( result == null ) {
final Object newObject = interceptor.getEntity( key.getEntityName(), key.getIdentifier() );
if ( newObject != null ) lock(newObject, LockMode.NONE);
return newObject;
}
else {
return result;
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.