-->
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: one-to-many & many-to-many problem while using composit
PostPosted: Thu Nov 08, 2007 4:26 am 
Newbie

Joined: Thu Nov 08, 2007 3:09 am
Posts: 1
Location: India
Hi friends,

I do have problem of using composite-id with one-to-many or many-to-many relationship in set tag.

I have two table TBLMNETCONFIGURATIONPARAMETER & TBLMNETCONFIGURATIONVALUES.
TBLMNETCONFIGURATIONPARAMETER has two composite key (1) parameterId (2) configId. And TBLMNETCONFIGURATIONVALUES has key (1) parameterId not configId.while mapping in configurationparameter.hbm.xml one-to-many or many-to-one give me this error.

java.lang.ClassCastException: java.lang.String
at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:329)
at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:284)
at org.hibernate.engine.CollectionLoadContext.getLoadingCollection(CollectionLoadContext.java:141)


Hibernate version:
3.0

Mapping documents:

netConfigurationParameterData.hbm.xml
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.elitecore.elitesm.datamanager.servermgr.data.NetConfigurationParameterData" table="TBLMNETCONFIGURATIONPARAMETER">

<composite-id name="parameterKey" class="com.elitecore.elitesm.datamanager.servermgr.data.NetConfigurationParameterDataKey">
<key-property column="PARAMETERID" name="parameterId" type="java.lang.String"/>
<key-property column="CONFIGID" name="configId" type="java.lang.String"/>
</composite-id>

<property name="parameterId" insert="false" update="false" access="field">
<column name="PARAMETERID" ></column>
</property>
<property name="configId" insert="false" update="false" access="field">
<column name="CONFIGID" ></column>
</property>

<property name="serialNo" type="int">
<column name="SERIALNO" sql-type="NUMBER(5)" not-null="true"></column>
</property>
.........................
<set name="netConfigParamValues" lazy="true" inverse="true">
<key property-ref="parameterId" />
<one-to-many class="com.elitecore.elitesm.datamanager.servermgr.data.NetConfigurationValuesData"/>
</set>

------------------------------------------------------------------------------------
netConfigurationParameterValue.hbm.xml
------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.elitecore.elitesm.datamanager.servermgr.data.NetConfigurationValuesData" table="TBLMNETCONFIGURATIONVALUES">
<id name="parameterValueId" column="PARAMETERVALUEID" type="string">
<generator class="com.elitecore.elitesm.hibernate.core.system.util.EliteSequenceGenerator">
<param name="eliteprefix">CNV</param>
<param name="elitefill">0</param>
<param name="elitelength">9</param>
</generator>
</id>
<property name="parameterId" type="string">
<column name="PARAMETERID" sql-type="CHAR(9)" not-null="true"></column>
</property>
</class>
</hibernate-mapping>

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

Session session = getSession();

Criteria criteria = session.createCriteria(NetConfigurationParameterData.class)
.add(Restrictions.eq("configId",configId))
.add(Restrictions.isNull("parentParameterId"));

Set stConfigParamSet = new HashSet();

System.out.println("This is criteria :"+criteria);

stConfigParamSet.addAll(criteria.list());
session.close()

Full stack trace of any exception that occurs:
This is criteria :CriteriaImpl(com.elitecore.elitesm.datamanager.servermgr.data.NetConfigurationParameterData:this[][configId=CNF0052, parentParameterId is null])
java.lang.ClassCastException: java.lang.String
at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:329)
at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:284)
at org.hibernate.engine.CollectionLoadContext.getLoadingCollection(CollectionLoadContext.java:141)
at org.hibernate.type.CollectionType.getCollection(CollectionType.java:488)
at org.hibernate.type.CollectionType.resolveKey(CollectionType.java:341)
at org.hibernate.type.CollectionType.resolve(CollectionType.java:335)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
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.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.elitecore.elitesm.hibernate.servermgr.server.HServerDataManager.getRootParameterConfigurationData(HServerDataManager.java:720)
at com.elitecore.elitesm.blmanager.servermgr.server.NetServerBLManager.createServerInstance(NetServerBLManager.java:325)
at com.elitecore.elitesm.web.servermgr.server.CreateServerAction.execute(CreateServerAction.java:81)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at com.elitecore.elitesm.web.core.system.servlet.EliteServlet.process(EliteServlet.java:30)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)
com.elitecore.elitesm.datamanager.DataManagerException: java.lang.String
at com.elitecore.elitesm.hibernate.servermgr.server.HServerDataManager.getRootParameterConfigurationData(HServerDataManager.java:734)
at com.elitecore.elitesm.blmanager.servermgr.server.NetServerBLManager.createServerInstance(NetServerBLManager.java:325)
at com.elitecore.elitesm.web.servermgr.server.CreateServerAction.execute(CreateServerAction.java:81)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at com.elitecore.elitesm.web.core.system.servlet.EliteServlet.process(EliteServlet.java:30)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassCastException: java.lang.String
at org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:329)
at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:284)
at org.hibernate.engine.CollectionLoadContext.getLoadingCollection(CollectionLoadContext.java:141)
at org.hibernate.type.CollectionType.getCollection(CollectionType.java:488)
at org.hibernate.type.CollectionType.resolveKey(CollectionType.java:341)
at org.hibernate.type.CollectionType.resolve(CollectionType.java:335)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
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.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.elitecore.elitesm.hibernate.servermgr.server.HServerDataManager.getRootParameterConfigurationData(HServerDataManager.java:720)
... 33 more

Name and version of the database you are using:
oracle9i.

The generated SQL (show_sql=true):
Hibernate: select this_.STAFFID as STAFFID13_0_, this_.NAME as NAME13_0_, this_.USERNAME as USERNAME13_0_, this_.CREATEDATE as CREATEDATE13_0_, this_.PASSWORD as PASSWORD13_0_, this_.BIRTHDATE as BIRTHDATE13_0_, this_.LASTMODIFIEDDATE as LASTMODI7_13_0_, this_.EMAILADDRESS as EMAILADD8_13_0_, this_.ADDRESS1 as ADDRESS9_13_0_, this_.ADDRESS2 as ADDRESS10_13_0_, this_.ZIP as ZIP13_0_, this_.CITY as CITY13_0_, this_.STATE as STATE13_0_, this_.COUNTRY as COUNTRY13_0_, this_.PHONE as PHONE13_0_, this_.LASTLOGINTIME as LASTLOG16_13_0_, this_.MOBILE as MOBILE13_0_, this_.STATUSCHANGEDATE as STATUSC18_13_0_, this_.COMMONSTATUSID as COMMONS19_13_0_, this_.CREATEDBYSTAFFID as CREATED20_13_0_, this_.LASTMODIFIEDBYSTAFFID as LASTMOD21_13_0_, this_.SYSTEMGENERATED as SYSTEMG22_13_0_ from TBLMSTAFF this_ where this_.USERNAME=?
Hibernate: select commonstat0_.COMMONSTATUSID as COMMONST1_6_0_, commonstat0_.SHOWHIDE as SHOWHIDE6_0_ from TBLSCOMMONSTATUS commonstat0_ where commonstat0_.COMMONSTATUSID=?
Hibernate: select staffgroup0_.staffId as staffId1_, staffgroup0_.STAFFID as STAFFID1_, staffgroup0_.GROUPID as GROUPID1_, staffgroup0_.STAFFID as STAFFID66_0_, staffgroup0_.GROUPID as GROUPID66_0_ from TBLMSTAFFGROUPREL staffgroup0_ where staffgroup0_.staffId=?
[ 08-Nov-2007 01:50:25 ] [ TRACE ] [ INIT CREATE SERVER ACTION ] : Entered execute method of com.elitecore.elitesm.web.servermgr.server.InitCreateServerAction
Hibernate: select this_.NETSERVERTYPEID as NETSERVE1_29_0_, this_.NAME as NAME29_0_, this_.ALIAS as ALIAS29_0_, this_.DESCRIPTION as DESCRIPT4_29_0_, this_.SYSTEMGENERATED as SYSTEMGE5_29_0_, this_.VERSION as VERSION29_0_ from TBLMNETSERVERTYPE this_ where this_.SYSTEMGENERATED=?
[ 08-Nov-2007 01:50:42 ] [ TRACE ] [ CREATE SERVER ] : Entered execute method of com.elitecore.elitesm.web.servermgr.server.CreateServerAction
Hibernate: select this_.NETSERVERTYPEID as NETSERVE1_29_0_, this_.NAME as NAME29_0_, this_.ALIAS as ALIAS29_0_, this_.DESCRIPTION as DESCRIPT4_29_0_, this_.SYSTEMGENERATED as SYSTEMGE5_29_0_, this_.VERSION as VERSION29_0_ from TBLMNETSERVERTYPE this_ where this_.NETSERVERTYPEID=? and this_.SYSTEMGENERATED=?
In create form the value of the version is :5.1.2.10-08
Hibernate: select SEQ_MNETSERVERINSTANCE.nextval from dual
Hibernate: select this_.NETSERVERTYPEID as NETSERVE1_29_0_, this_.NAME as NAME29_0_, this_.ALIAS as ALIAS29_0_, this_.DESCRIPTION as DESCRIPT4_29_0_, this_.SYSTEMGENERATED as SYSTEMGE5_29_0_, this_.VERSION as VERSION29_0_ from TBLMNETSERVERTYPE this_ where this_.NETSERVERTYPEID=?
Hibernate: select this_.NETSERVERTYPEID as NETSERVE1_39_0_, this_.NETSERVERVERSION as NETSERVE2_39_0_, this_.CONFIGVERSION as CONFIGVE3_39_0_ from TBLNETSERVERCONFIGVERSION this_ where this_.NETSERVERTYPEID=? and this_.NETSERVERVERSION=? order by this_.NETSERVERTYPEID asc
Hibernate: select this_.NETSERVERTYPEID as NETSERVE1_31_0_, this_.NETCONFIGID as NETCONFI2_31_0_, this_.NETCONFIGMAPTYPEID as NETCONFI3_31_0_ from TBLMNETSERVERCONFIGMAP this_ where this_.NETSERVERTYPEID=? order by this_.NETCONFIGMAPTYPEID asc
Hibernate: select this_.NETCONFIGID as NETCONFI1_21_0_, this_.SERIALNO as SERIALNO21_0_, this_.NAME as NAME21_0_, this_.DISPLAYNAME as DISPLAYN4_21_0_, this_.FILENAME as FILENAME21_0_, this_.ALIAS as ALIAS21_0_, this_.CONFIGVERSION as CONFIGVE7_21_0_ from TBLMNETCONFIGURATION this_ where this_.NETCONFIGID=? and this_.CONFIGVERSION=? order by this_.NETCONFIGID asc
Hibernate: select this_.NETCONFIGID as NETCONFI1_21_0_, this_.SERIALNO as SERIALNO21_0_, this_.NAME as NAME21_0_, this_.DISPLAYNAME as DISPLAYN4_21_0_, this_.FILENAME as FILENAME21_0_, this_.ALIAS as ALIAS21_0_, this_.CONFIGVERSION as CONFIGVE7_21_0_ from TBLMNETCONFIGURATION this_ where this_.NETCONFIGID=? and this_.CONFIGVERSION=? order by this_.NETCONFIGID asc
Hibernate: select this_.NETCONFIGID as NETCONFI1_21_0_, this_.SERIALNO as SERIALNO21_0_, this_.NAME as NAME21_0_, this_.DISPLAYNAME as DISPLAYN4_21_0_, this_.FILENAME as FILENAME21_0_, this_.ALIAS as ALIAS21_0_, this_.CONFIGVERSION as CONFIGVE7_21_0_ from TBLMNETCONFIGURATION this_ where this_.NETCONFIGID=? and this_.CONFIGVERSION=? order by this_.NETCONFIGID asc
Hibernate: select this_.NETCONFIGID as NETCONFI1_21_0_, this_.SERIALNO as SERIALNO21_0_, this_.NAME as NAME21_0_, this_.DISPLAYNAME as DISPLAYN4_21_0_, this_.FILENAME as FILENAME21_0_, this_.ALIAS as ALIAS21_0_, this_.CONFIGVERSION as CONFIGVE7_21_0_ from TBLMNETCONFIGURATION this_ where this_.NETCONFIGID=? and this_.CONFIGVERSION=? order by this_.NETCONFIGID asc
Hibernate: select SEQ_MNETCONFIGURATIONINSTANCE.nextval from dual
This is criteria :CriteriaImpl(com.elitecore.elitesm.datamanager.servermgr.data.NetConfigurationParameterData:this[][configId=CNF0052, parentParameterId is null])
Hibernate: select this_.PARAMETERID as PARAMETE1_23_0_, this_.CONFIGID as CONFIGID23_0_, this_.SERIALNO as SERIALNO23_0_, this_.NAME as NAME23_0_, this_.DISPLAYNAME as DISPLAYN5_23_0_, this_.ALIAS as ALIAS23_0_, this_.DESCRIPTION as DESCRIPT7_23_0_, this_.TYPE as TYPE23_0_, this_.REGEXP as REGEXP23_0_, this_.MAXINSTANCES as MAXINST10_23_0_, this_.MULTIPLEINSTANCES as MULTIPL11_23_0_, this_.PARENTPARAMETERID as PARENTP12_23_0_, this_.DEFAULTVALUE as DEFAULT13_23_0_, this_.MAXLENGTH as MAXLENGTH23_0_, this_.EDITABLE as EDITABLE23_0_, this_.STARTUPMODE as STARTUP16_23_0_, this_.STATUS as STATUS23_0_ from TBLMNETCONFIGURATIONPARAMETER this_ where this_.CONFIGID=? and this_.PARENTPARAMETERID is null

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?
no

Read this: http://hibernate.org/42.html

Please help to solve this problem.I will not say thanx in advance like other people....o.k thanx now....

_________________
I am Happy working with j2ee.


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.