-->
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: Caching
PostPosted: Wed Jan 05, 2005 11:28 am 
Beginner
Beginner

Joined: Tue Dec 21, 2004 3:18 am
Posts: 32
Hi,
I was trying to use caching in hibernate but I got this error.

Exception in thread "main" java.lang.NullPointerException
at net.sf.ehcache.config.Configuration$DefaultCache.access$100(Configuration.java:308)
at net.sf.ehcache.config.Configuration.getDefaultCache(Configuration.java:129)
at net.sf.ehcache.CacheManager.configure(CacheManager.java:159)
at net.sf.ehcache.CacheManager.<init>(CacheManager.java:128)
at net.sf.ehcache.CacheManager.create(CacheManager.java:180)
at net.sf.ehcache.CacheManager.getInstance(CacheManager.java:196)
at net.sf.ehcache.hibernate.Plugin.<init>(Plugin.java:92)
at net.sf.ehcache.hibernate.Provider.buildCache(Provider.java:89)
at net.sf.hibernate.cfg.Configuration.configureCaches(Configuration.java:1135)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:795)
at hibernate2package.Main.main(Main.java:190)

Could anyone please help me in that.

Thanks in Advance.

Hibernate version:
2.1
Mapping documents:
Customer:

<?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 package="hibernate2package">
<class name = "Customer" table ="customer">
<cache usage="read-write" />

<id name="cid" column ="cid">
<generator class ="native"/>
</id>
<property name="cname" column="name"/>
<property name="caddress" column="address"/>
<property name="ctel" column="tel"/>

<bag name="products" table="customerproduct" lazy="true" cascade="save-update">
<cache usage="read-write" />
<key column= "custid"/>
<many-to-many class="Product" column="prodid"/>
</bag>
</class>
</hibernate-mapping>

Product:
<?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 package="hibernate2package">

<class name="Product" table="product">
<cache usage="read-write" />

<id name = "pid" column ="pid">
<generator class="native"/>
</id>
<property name= "pname" column="name"/>
<property name="pdescription" column="description"/>

<bag name="customers" table ="customerproduct" lazy="true" inverse="true" cascade="save-update">
<cache usage="read-write" />
<key column= "prodid"/>
<many-to-many class="Product" column="custid"/>
</bag>
<many-to-one name="vendor" column="vid" class="Vendor"/>

</class>

</hibernate-mapping>

Vendor:
<?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 package="hibernate2package">
<class name="Vendor" table="vendor">
<id name="vid" column="vid">
<generator class="native"/>
</id>
<property name="vname" column="name"/>
<property name="vaddress" column="address"/>
<property name="vtel" column="tel"/>
<bag name="products" inverse="true" lazy ="true" cascade="all-delete-orphan">
<key column="vid"/>
<one-to-many class="Product"/>
</bag>
</class>
</hibernate-mapping>

ehcahe.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<cache name="hibernate2package.Customer"
maxElementsInMemory="500"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
/>

<cache name="hibernate2package.Customer.products"
maxElementsInMemory="500"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
/>

<cache name="hibernate2package.Product"
maxElementsInMemory="500"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
/>

<cache name="hibernate2package.Product.customers"
maxElementsInMemory="500"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
/>

</ehcache>

hibernate.properties:
hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class org.gjt.mm.mysql.Driver
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql:///mydb2
hibernate.connection.username root
hibernate.connection.password
hibernate.cache.provider_class net.sf.ehcache.hibernate.Provider
hibernate.cache.use_query_cache true



Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
mysql

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 06, 2005 3:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
update to the latest release of hibernate. there is a fixed version of ehcache with it.

_________________
Emmanuel


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.