-->
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.  [ 3 posts ] 
Author Message
 Post subject: Second-level cache and custom UserTypes
PostPosted: Wed Dec 15, 2004 1:13 pm 
Newbie

Joined: Mon Aug 02, 2004 3:02 pm
Posts: 15
Hello,

I have implemented Gavin's blog on Internationalized Data http://blog.hibernate.org/cgi-bin/blosxom.cgi/2004/06/23#i18n) and have implemented the second-level cache as shown below for a Label hibernate class. For some reason, it appears as though the Label objects are never being cached as I never see a "adding entity to second-level cache" or any sort of ehcache debug statements.

Is there something else that I need to do to have the Label objects cached? I see the cache debugs for my other objects so I know that the cache is working.

Thanks for any help,

Rexxe

Hibernate version: 2.1.7

Mapping documents: Only relevant part of mapping shown.
Code:
<class
        name="foo.dto.Label"
        table="LABEL"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
        optimistic-lock="version"
    >
        <cache usage="read-only" />
       


Code between sessionFactory.openSession() and session.close():Using Spring:
Code:
public String getDescription(Long code, Locale locale) {
        String query = "select l.description from foo.dto.Label l "
                + "where l.id.code = (:code) and l.id.language = (:language)";

        return (String) getHibernateTemplate().findByNamedParam(query,
                new String[] { "code", "language" },
                new Object[] { code, locale.getLanguage() }).get(0);
    }


Name and version of the database you are using: PostgreSQL 8.0 Beta 4 on Win XP Pro

The generated SQL (show_sql=true):
Code:
[DEBUG] 11:23:20 SQL - select label0_.description as x0_0_ from LABEL label0_ where (label0_.code=(?))and(label0_.language=(?))


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 1:50 pm 
Beginner
Beginner

Joined: Thu Jul 29, 2004 7:14 pm
Posts: 41
Can you post your SQL DDL?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 15, 2004 1:58 pm 
Newbie

Joined: Mon Aug 02, 2004 3:02 pm
Posts: 15
Here is the DDL:

Code:
CREATE TABLE label
(
  code int8 NOT NULL,
  "language" varchar(255) NOT NULL,
  version_id int4 NOT NULL,
  description varchar(255) NOT NULL,
  CONSTRAINT label_pkey PRIMARY KEY (code, "language")
)


Thanks,

Rexxe


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.