-->
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: Mapping list (Informix collection datatype)
PostPosted: Tue Dec 05, 2006 11:32 am 
Newbie

Joined: Tue Dec 05, 2006 11:09 am
Posts: 1
Hi all,
I am using Informix 9.0 with Hibernate version 3.0.5.
I have a table with column of type list (Informix collection datatype).
Hibernate Tools plugin generated the mapping for the column as java.lang.Object.
when i used it like that i get the error saying that

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'campaignFolderDAO' defined in class path resource [test/spring.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [test/spring.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: property mapping has wrong number of columns: com.intellicast.model.IntellCampaignRecipientData.recipientrowvalues type: object
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [test/spring.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: property mapping has wrong number of columns: com.intellicast.model.IntellCampaignRecipientData.recipientrowvalues type: object
org.hibernate.MappingException: property mapping has wrong number of columns: com.intellicast.model.IntellCampaignRecipientData.recipientrowvalues type: object
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:326)
at org.hibernate.mapping.RootClass.validate(RootClass.java:188)
at org.hibernate.cfg.Configuration.validate(Configuration.java:839)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1000)


so i changed the mapping files like below.




<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.intellicast.model.IntellCampaignRecipientData" table="intell_campaign_recipient_data">
<composite-id name="id" class="com.intellicast.model.IntellCampaignRecipientDataId">
<key-many-to-one name="intellCampaignChannels" class="com.intellicast.model.IntellCampaignChannels">
<column name="campaignid" />
<column name="campaignchannelind" />
</key-many-to-one>
<key-property name="recipientrownum" type="integer">
<column name="recipientrownum" />
</key-property>
</composite-id>
<property name="recipientrowvalues" type="java.util.ArrayList">
<column name="recipientrowvalues" />
</property>
</class>
</hibernate-mapping>



package com.intellicast.model;


import java.sql.Array;
import java.util.List;


/**
* IntellCampaignRecipientData generated by hbm2java
*/
public class IntellCampaignRecipientData implements java.io.Serializable {

// Fields

private IntellCampaignRecipientDataId id;
private List recipientrowvalues;


// Constructors

/** default constructor */
public IntellCampaignRecipientData() {
}

/** constructor with id */
public IntellCampaignRecipientData(IntellCampaignRecipientDataId id) {
this.id = id;
}




// Property accessors

/**
*
*/
public IntellCampaignRecipientDataId getId() {
return this.id;
}

public void setId(IntellCampaignRecipientDataId id) {
this.id = id;
}

/**
*
*/
public List getRecipientrowvalues() {
return this.recipientrowvalues;
}

public void setRecipientrowvalues(List recipientrowvalues) {
this.recipientrowvalues = recipientrowvalues;
}



}


List list = getHibernateTemplate().find("FROM IntellCampaignRecipientData data where data.id.intellCampaignChannels.id.intellCampaigns.campaignid = 643 and data.id.intellCampaignChannels.id.campaignchannelind =2");
if(list.size() > 0)
{
IntellCampaignRecipientData data = (IntellCampaignRecipientData)list.get(0);
System.out.println(data.getRecipientrowvalues());
}

With this mapping i get this error.

Hibernate: select intellcamp0_.campaignid as campaignid, intellcamp0_.campaignchannelind as campaign2_, intellcamp0_.recipientrownum as recipien3_, intellcamp0_.recipientrowvalues as recipien4_42_ from intell_campaign_recipient_data intellcamp0_, intell_campaign_channels intellcamp1_, intell_campaigns intellcamp2_ where intellcamp1_.campaignid=intellcamp2_.campaignid and intellcamp0_.campaignid=intellcamp1_.campaignid and intellcamp0_.campaignchannelind=intellcamp1_.campaignchannelind and intellcamp2_.campaignid=643 and intellcamp1_.campaignchannelind=2
- SQL Error: -79741, SQLState: IX000
- Can't convert to: byte array


org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select intellcamp0_.campaignid as campaignid, intellcamp0_.campaignchannelind as campaign2_, intellcamp0_.recipientrownum as recipien3_, intellcamp0_.recipientrowvalues as recipien4_42_ from intell_campaign_recipient_data intellcamp0_, intell_campaign_channels intellcamp1_, intell_campaigns intellcamp2_ where intellcamp1_.campaignid=intellcamp2_.campaignid and intellcamp0_.campaignid=intellcamp1_.campaignid and intellcamp0_.campaignchannelind=intellcamp1_.campaignchannelind and intellcamp2_.campaignid=643 and intellcamp1_.campaignchannelind=2]; SQL state [IX000]; error code [-79741]; Can't convert to: byte array; nested exception is java.sql.SQLException: Can't convert to: byte array
java.sql.SQLException: Can't convert to: byte array
at com.informix.util.IfxErrMsg.getSQLMinorException(IfxErrMsg.java:512)
at com.informix.jdbc.IfxObject.toBytes(IfxObject.java:554)
at com.informix.jdbc.IfxResultSet.getBytes(IfxResultSet.java:1194)
at com.informix.jdbc.IfxResultSet.getBytes(IfxResultSet.java:1209)
at org.apache.commons.dbcp.DelegatingResultSet.getBytes(DelegatingResultSet.java:252)
at org.hibernate.type.BinaryType.get(BinaryType.java:64)
at org.hibernate.type.SerializableType.get(SerializableType.java:34)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80)
at org.hibernate.persister.entity.BasicEntityPersister.hydrate(BasicEntityPersister.java:1690)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:991)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:942)
at org.hibernate.loader.Loader.getRow(Loader.java:855)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:305)
at org.hibernate.loader.Loader.doQuery(Loader.java:412)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:766)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:315)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:757)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:749)
at com.intellicast.campaignrecipientfileformat.dao.impl.CampaignRecipientFileFormatDAOHibernate.getCampaignRecipientDetails(CampaignRecipientFileFormatDAOHibernate.java:759)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy4.getCampaignRecipientDetails(Unknown Source)
at com.intellicast.campaignrecipientfileformat.service.impl.CampaignRecipientFileFormatServiceImpl.getCampaignRecipientDetails(CampaignRecipientFileFormatServiceImpl.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)


***************************************************
A JDBC implementation.. works

String strCampaignRecipientDataFeedQuery = SELECT recipientrownum,recipientrowvalues FROM intell_campaign_recipient_data WHERE campaignid = iCampaignID AND campaignchannelind = iCampaignChannelInd;

Connection con = session.connection();
Statement stmt = con.createStatement();
CampaignRecipientDataFeed[] campaignRecipientDataFeedArr = null;
ResultSet rs = stmt.executeQuery(strCampaignRecipientDataFeedQuery);
List listCampaignDetails = new ArrayList();
while (rs.next())
{
CampaignRecipientDataFeed campaignRecipientDataFeedObj = new CampaignRecipientDataFeed();
campaignRecipientDataFeedObj.setIRecipientRowNum(rs.getInt(1));
List list = (List)rs.getObject(2);
String strArr[] = null;
if (list != null)
{
strArr = new String[list.size()];
list.toArray(strArr);
}
campaignRecipientDataFeedObj.setStrRecipientRowValueList(strArr);
listCampaignDetails.add(campaignRecipientDataFeedObj);
}

Please kindly tell me how to proceed??


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.