-->
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.  [ 1 post ] 
Author Message
 Post subject: Caching null values?
PostPosted: Thu Dec 16, 2004 12:33 pm 
Newbie

Joined: Tue May 11, 2004 11:32 am
Posts: 16
I have two classes with one-to-one mappings between them. The User class is read-write. Every user *might* have a Status object. The STATUS table is populated externally (by an stored database procedure) and is read-only as far as my application is concerned.

Both User and Status are cached.

My question is: is there a way to cache the fact that a particular user does not have a Status? I have a page that loads 5 users. 2 of these users do not have a corresponding row in the STATUS table. The first time the page loads I see 5 queries for Status. The second time (and each subsequent time) there are 2 queries for the Status object.

I'd like to remember the fact that Status is missing for those 2 Users and only check again when the cache entry expires.

Is this possible? If not, has anyone come up with a way to do this?

thanks
sam

ps - The User cache timeout is very long as they change very infrequently. The Status cache timeout is much shorter as it changes more frequently (via a stored procedure). The Status class is also lazy... as I frequently don't even care about it.


Hibernate version: 2.1.7

Mapping documents:
Code:
<class name="User" table="USER">
  <cache usage="read-write"/>
  <id name="id" column="USER_ID">
    <generator class="sequence">
      <param name="sequence">USER_SEQ</param>
    </generator>
  </id>
  <property name="firstName" column="FIRST_NAME" type="string"/>
  <property name="lastName" column="LAST_NAME" type="string"/>
  <one-to-one name="status" class="Status"/>
</class>

<class name="Status" table="STATUS" lazy="true">
  <cache usage="read-only"/>
  <id name="id" column="USER_ID">
    <generator class="foreign">
      <param name="property">user</param>
    </generator>
  </id>
  <property name="currentStatus" column="STATUS" type="string"/>
  <one-to-one name="user" class="User" constrained="true"/>
</class>


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

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.