-->
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.  [ 2 posts ] 
Author Message
 Post subject: mysql secondary-cache query cache
PostPosted: Wed Dec 01, 2004 6:21 am 
Regular
Regular

Joined: Sat Feb 21, 2004 8:54 pm
Posts: 60
Location: Lakewood, California
hi, still tryin to get the secondary-cache to work with queries. i made simpler example of just one tabel with one extra field.

i still get the following with mutable and read-write.

01:45:45,260 DEBUG SQL:237 - select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
Hibernate: select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
01:45:45,370 DEBUG QueryCache:46 - caching query results in region: net.sf.hibernate.cache.QueryCache
01:45:45,370 INFO QC:25 - db1.hibernate.T1@e61fd1[id=1]
01:45:45,430 DEBUG QueryCache:61 - checking cached query results in region: net.sf.hibernate.cache.QueryCache
01:45:45,430 DEBUG QueryCache:64 - query results were not found in cache
01:45:45,430 DEBUG SQL:237 - select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
Hibernate: select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )

with read-only, and mutable=false, i get:
01:56:57,220 DEBUG SQL:237 - select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
Hibernate: select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
01:56:57,390 DEBUG ReadOnlyCache:44 - Caching: 1
01:56:57,390 DEBUG QueryCache:46 - caching query results in region: net.sf.hibernate.cache.QueryCache
01:56:57,390 INFO QC:25 - db1.hibernate.T1@bad8a8[id=1]
01:56:57,500 DEBUG QueryCache:61 - checking cached query results in region: net.sf.hibernate.cache.QueryCache
01:56:57,500 DEBUG QueryCache:64 - query results were not found in cache
01:56:57,500 DEBUG SQL:237 - select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
Hibernate: select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )

so it looks like he put's it in the read only cache, but stilll can't find it.

my data is really read only, but i need to get it by a query, not by it's pk..

has anyone got this to work?

does anyone have any ideas about what i might be doing wrong?

does anyone know how to get and set the mutable and cache properties from the configuration? that way i could get an more exhaustive example to run automatically.

amy pointers will be appreciated.

thanks

Hibernate version:
2.1.3
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name='db1.hibernate.T1' mutable='true' >
<cache usage="read-write"/>
<id name='id' type='java.lang.Integer'><generator class='native'/></id>
<property name='field1' type='java.lang.String' length='100' unique='true'/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
import java.util.*;
import org.apache.log4j.*;
import net.sf.hibernate.*;
import net.sf.hibernate.cfg.*;
import net.sf.hibernate.mapping.PersistentClass;
import db1.hibernate.T1;
public class QC {
void run() throws Exception {
logger.info("run");
final String value="record 0 after 0";
final PersistentClass pc=c.getClassMapping(T1.class);
//db1.hibernate.T1
for(int i=0;i<loggers.length;i++)
Logger.getLogger(loggers[i]).setLevel(Level.ALL);
for(int i=0;i<3;i++) {
s=sf.openSession();
tx=s.beginTransaction();
Query t1ByValue=s.createQuery("from T1 l where l.field1=:value");
t1ByValue.setString("value",value);
t1ByValue.setCacheable(true);
l=t1ByValue.list();
if(l==null||l.size()!=1) throw new RuntimeException("lose");
t=(T1)l.get(0);
if(t==null||!t.getField1().equals(value)) throw new RuntimeException("lose");
logger.info(t);
tx.commit();
s.close();
}
sf.close();
}
public static void main(String[] argument) throws Exception {
(new QC()).run();
}
final Logger logger=Logger.getLogger(this.getClass());
{
logger.setLevel(Level.INFO);
}
T1 t;
List l;
Session s;
Transaction tx;
final Configuration c;
final SessionFactory sf;
{
try {
c=new Configuration();
c.setProperty("hibernate.connection.url",staticUrlBase+"db1");
c.setProperty("hibernate.show_sql","true");
//if(create) c.setProperty(Environment.HBM2DDL_AUTO,"create");
c.addClass(T1.class);
sf=c.buildSessionFactory();
} catch(Exception e) {
throw new RuntimeException(e);
}
}
static final String[] loggers={"net.sf.hibernate.SQL","net.sf.hibernate.cache.ReadOnlyCache","net.sf.hibernate.cache.UpdateTimestampsCache","net.sf.hibernate.cache.QueryCache","net.sf.hibernate.cache.CacheFactory"};
static final String userName=System.getProperty("user.name");
static final String staticUrlBase=userName.equals("rtayek")?"jdbc:mysql://204.1.213.186:3306/":"jdbc:mysql://tayek.com/";
}
Full stack trace of any exception that occurs:

Name and version of the database you are using:
mysql version 12.22 dist 4.0.18 on win98/se
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
01:45:41,250 INFO Environment:462 - Hibernate 2.1.3
01:45:41,310 INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql://tayek.com:3306/test, hibernate.connection.password=, hibernate.connection.pool_size=1}
01:45:41,310 INFO Environment:518 - using java.io streams to persist binary types
01:45:41,310 INFO Environment:519 - using CGLIB reflection optimizer
01:45:41,360 INFO Configuration:347 - Mapping resource: db1/hibernate/T1.hbm.xml
01:45:42,130 INFO Binder:229 - Mapping class: db1.hibernate.T1 -> T1
01:45:42,520 INFO Configuration:613 - processing one-to-many association mappings
01:45:42,520 INFO Configuration:622 - processing one-to-one association property references
01:45:42,520 INFO Configuration:647 - processing foreign key constraints
01:45:42,630 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.MySQLDialect
01:45:42,630 INFO SettingsFactory:58 - Maximim outer join fetch depth: 1
01:45:42,630 INFO SettingsFactory:62 - Use outer join fetching: false
01:45:42,680 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
01:45:42,680 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 1
01:45:42,680 INFO DriverManagerConnectionProvider:77 - using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://tayek.com/db1
01:45:42,740 INFO DriverManagerConnectionProvider:78 - connection properties: {user=root, password=}
01:45:42,740 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
01:45:43,290 INFO SettingsFactory:102 - Use scrollable result sets: true
01:45:43,290 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): true
01:45:43,290 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
01:45:43,290 INFO SettingsFactory:114 - echoing all SQL to stdout
01:45:43,290 INFO SettingsFactory:117 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
01:45:43,290 INFO SettingsFactory:128 - cache provider: net.sf.hibernate.cache.HashtableCacheProvider
01:45:43,290 INFO Configuration:1093 - instantiating and configuring caches
01:45:43,890 INFO SessionFactoryImpl:119 - building session factory
01:45:44,820 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
01:45:44,820 INFO UpdateTimestampsCache:35 - starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
01:45:44,820 INFO QueryCache:39 - starting query cache at region: net.sf.hibernate.cache.QueryCache
01:45:44,820 INFO QC:9 - run
01:45:45,260 DEBUG QueryCache:61 - checking cached query results in region: net.sf.hibernate.cache.QueryCache
01:45:45,260 DEBUG QueryCache:64 - query results were not found in cache
01:45:45,260 DEBUG SQL:237 - select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
Hibernate: select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
01:45:45,370 DEBUG QueryCache:46 - caching query results in region: net.sf.hibernate.cache.QueryCache
01:45:45,370 INFO QC:25 - db1.hibernate.T1@e61fd1[id=1]
01:45:45,430 DEBUG QueryCache:61 - checking cached query results in region: net.sf.hibernate.cache.QueryCache
01:45:45,430 DEBUG QueryCache:64 - query results were not found in cache
01:45:45,430 DEBUG SQL:237 - select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
Hibernate: select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
01:45:45,430 DEBUG QueryCache:46 - caching query results in region: net.sf.hibernate.cache.QueryCache
01:45:45,430 INFO QC:25 - db1.hibernate.T1@da3a1e[id=1]
01:45:45,480 DEBUG QueryCache:61 - checking cached query results in region: net.sf.hibernate.cache.QueryCache
01:45:45,480 DEBUG QueryCache:64 - query results were not found in cache
01:45:45,480 DEBUG SQL:237 - select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
Hibernate: select t10_.id as id, t10_.field1 as field1 from T1 t10_ where (t10_.field1=? )
01:45:45,480 DEBUG QueryCache:46 - caching query results in region: net.sf.hibernate.cache.QueryCache
01:45:45,480 INFO QC:25 - db1.hibernate.T1@c5495e[id=1]
01:45:45,480 INFO SessionFactoryImpl:531 - closing
01:45:45,480 INFO DriverManagerConnectionProvider:143 - cleaning up connection pool: jdbc:mysql://tayek.com/db1

_________________
<http://tayek.com/>, co-chair <http://www.ocjug.org/>, actively
seeking telecommuting work. hate spam?
<https://www1.ietf.org/mailman/listinfo/asrg>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 03, 2004 10:25 am 
Regular
Regular

Joined: Sat Feb 21, 2004 8:54 pm
Posts: 60
Location: Lakewood, California
apparentlya bug in the verion

_________________
<http://tayek.com/>, co-chair <http://www.ocjug.org/>, actively
seeking telecommuting work. hate spam?
<https://www1.ietf.org/mailman/listinfo/asrg>


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