Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.2.0.g.a
or even with earlier versions "3.0.5".
Mapping documents:
userValue.xml
<hibernate-mapping>
<class name="com.geodesiconline.xmpp.value.db.UserValue" table="userinfo" lazy="false">
<cache usage="transactional" region="/UserValue"/>
<id name="username"></id>
<property name="alias"/>
<property name="emailid"/>
<set name="roster" inverse="true" table="roster" lazy="false" fetch="join" outer-join="true" cascade="all-delete-orphan">
<cache usage="transactional" region="UserValue/RosterValue"/>
<key>
<column name="username"/>
</key>
<one-to-many class="com.geodesiconline.xmpp.value.db.RosterValue" />
</set>
</class>
</hibernate-mapping>
database table structure
create table userinfo(username varchar not null, alias varchar, emailid varchar, constraint uname_pk primary key(username))
RosterValue.xml
<hibernate-mapping>
<class name="com.geodesiconline.xmpp.value.db.RosterValue" table="roster" lazy="false" batch-size="20">
<cache usage="transactional" region="UserValue/RosterValue"/>
<composite-id>
<key-property name="username"/>
<key-property name="contactjid"/>
</composite-id>
<property name="contactalias"/>
<property name="subscriptionState" column="subscriptionstate" type="integer"/>
<set name="grouplist" inverse="true" table="contactgroup" fetch="join" outer-join="true" lazy="false" cascade="all-delete-orphan">
<cache usage="transactional" region="RosterValue/ContactGroup"/>
<key>
<column name="username"/>
<column name="contactjid"/>
</key>
<one-to-many class="com.geodesiconline.xmpp.value.db.ContactGroup" />
</set>
</class>
</hibernate-mapping>
database table structure
create table roster(username varchar, contactjid varchar, contactalias varchar, subscriptionstate integer,constraint ros_uk unique(username, contactjid), constraint username_fk foreign key (username)references userinfo(username))
ContactGroup.xml
<hibernate-mapping>
<class name="com.geodesiconline.xmpp.value.db.ContactGroup" table="contactgroup" lazy="false">
<cache usage="transactional" region="RosterValue/ContactGroup"/>
<composite-id>
<key-property name="username"/>
<key-property name="contactjid"/>
<key-property name="groupname" column="groupname" length="64"/>
</composite-id>
</class>
</hibernate-mapping>
database table structure
create table contactgroup(username varchar(1023), contactjid varchar(2047),
groupname varchar(64), constraint cont_pk primary key(username, contactjid, groupname)
, constraint contuname_fk foreign key (username, contactjid)references roster(username, contactjid))
Code between sessionFactory.openSession() and session.close():
UserValue userValue = null;
try
{
userValue = (UserValue) session.load( UserValue.class, argUserid );
}
catch( UnresolvableObjectException e1 )
{
if( !( e1 instanceof ObjectDeletedException ) )
userValue = (UserValue) session.get( UserValue.class, argUserid );
}
return userValue.getRoster();
Full stack trace of any exception that occurs:
2006-11-02 19:56:08,767 [RosterDAO-getRoster():109] ERROR - exception while getRoster for username user4949
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.geodesiconline.xmpp.value.db.ContactGroup.username
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:64)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:70)
at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:83)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:353)
at org.hibernate.type.ComponentType.isEqual(ComponentType.java:123)
at org.hibernate.cache.CacheKey.equals(CacheKey.java:51)
at java.util.HashMap.getEntry(HashMap.java:349)
at java.util.LinkedHashMap.get(LinkedHashMap.java:280)
at net.sf.ehcache.store.MemoryStore.get(MemoryStore.java:129)
at net.sf.ehcache.Cache.searchInMemoryStore(Cache.java:721)
at net.sf.ehcache.Cache.get(Cache.java:549)
at org.hibernate.cache.EhCache.get(EhCache.java:74)
at org.hibernate.cache.EhCache.read(EhCache.java:92)
at org.hibernate.cache.TransactionalCache.put(TransactionalCache.java:45)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:156)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadCollectionBatch(Loader.java:1956)
at org.hibernate.loader.collection.BatchingCollectionInitializer.initialize(BatchingCollectionInitializer.java:47)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:755)
at org.hibernate.event.def.DefaultLoadEventListener.assembleCacheEntry(DefaultLoadEventListener.java:567)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:494)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:356)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:137)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:101)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:795)
at org.hibernate.impl.SessionImpl.load(SessionImpl.java:788)
at com.geodesiconline.xmpp.dao.hibernate.RosterDAO.getRoster(RosterDAO.java:88)
at com.geodesiconline.xmpp.dao.hibernate.RosterDAO.getRosterWithoutGroup(RosterDAO.java:122)
at com.geodesiconline.xmpp.util.DAOUtil.getRosterWithoutGroup(DAOUtil.java:187)
at com.geodesiconline.xmpp.handler.StanzaHandler.getRosterWithoutGroup(StanzaHandler.java:406)
at com.geodesiconline.xmpp.handler.PresenceHandler.processOutboundStanza(PresenceHandler.java:155)
at com.geodesiconline.xmpp.handler.AsynchronousStanzaHandler.processStanza(AsynchronousStanzaHandler.java:247)
at com.geodesiconline.xmpp.handler.StanzaHandler.processElement(StanzaHandler.java:136)
at com.geodesiconline.xmpp.handler.AbstractHandler.handleStanza(AbstractHandler.java:145)
at com.geodesiconline.xmpp.XMPPController.process(XMPPController.java:836)
at com.geodesiconline.xmpp.XMPPController.cleanUpSession(XMPPController.java:479)
at com.geodesiconline.xmpp.XMPPController.sessionClosed(XMPPController.java:412)
at com.geodesiconline.xmpp.XMPPController.onMessage(XMPPController.java:1004)
at com.geodesiconline.mjms.MJmsMessageConsumer.onMessage(MJmsMessageConsumer.java:40)
at com.geodesiconline.mjms.MJmsTopicSubscriber.onMessage(MJmsTopicSubscriber.java:63)
at com.geodesiconline.mjms.MJmsTopic.notifySubscribers(MJmsTopic.java:283)
at com.geodesiconline.mjms.MJmsTopic$Notifier.run(MJmsTopic.java:79)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:679)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:704)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@6b262721
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:589)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
Name and version of the database you are using:
using MYSQL
versio "Ver 14.12 Distrib 5.0.22"
The generated SQL (show_sql=true):
select uservalue0_.username as username9_6_, uservalue0_.alias as alias9_6_, uservalue0_.emailid as emailid9_6_, roster1_.username as username8_, roster1_.contactjid as contactjid8_, roster1_.username as username7_0_, roster1_.contactjid as contactjid7_0_, roster1_.contactalias as contacta3_7_0_, roster1_.subscriptionstate as subscrip4_7_0_, grouplist2_.username as username9_, grouplist2_.contactjid as contactjid9_, grouplist2_.groupname as groupname9_, grouplist2_.username as username1_1_, grouplist2_.contactjid as contactjid1_1_, grouplist2_.groupname as groupname1_1_ from userinfo uservalue0_ left outer join roster roster1_ on uservalue0_.username=roster1_.username left outer join contactgroup grouplist2_ on roster1_.username=grouplist2_.username and roster1_.contactjid=grouplist2_.contactjid where uservalue0_.username=?
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
using Ehcache for second level cacheing.
version ehcache-1.2.jar
with respect to above mentaion details
I could run the smoke test for my application, but during the load test above mention problems occurs with different users.
I'd appreciate any help or suggestions.
Thank you.