Hibernate version: 2.1.4
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.caliari.nova.ietm.DataModuleInfo" table="DATA_MODULES">
<id name="id" column="DM_ID" type="string" length="32">
<generator class="uuid.hex"/>
</id>
<property name="dmc" column="DMC" type="string" not-null="true"/>
<property name="type" column="TYPE" type="char"/>
<property name="techname" column="TECHNAME" type="string"/>
<property name="note" column="NOTE" type="string" length="4000"/>
<set name="items" inverse="true" cascade="all-delete-orphan">
<key column="DM_ID"/>
<one-to-many class="com.caliari.nova.ietm.ItemInfo"/>
</set>
</class>
<class name="com.caliari.nova.ietm.ItemInfo" table="IETM_ITEMS">
<id name="id" column="ITEM_ID" type="string" length="32">
<generator class="uuid.hex"/>
</id>
<property name="pn" column="PN" type="string" not-null="true" length="40"/>
<many-to-one name="dmc" class="com.caliari.nova.ietm.DataModuleInfo" column="DM_ID" cascade="all" not-null="true"/>
<set name="systems" inverse="true" cascade="all-delete-orphan">
<key column="ITEM_ID"/>
<one-to-many class="com.caliari.nova.ietm.SystemInfo"/>
</set>
</class>
<class name="com.caliari.nova.ietm.SystemInfo" table="IETM_SYSTEMS">
<id name="id" column="SYSTEM_ID" type="string" length="32">
<generator class="uuid.hex"/>
</id>
<property name="name" column="NAME" type="string"/>
<many-to-one name="item" class="com.caliari.nova.ietm.ItemInfo" column="ITEM_ID" cascade="all" not-null="true"/>
<set name="lcns" table="IETM_LCNS" inverse="true" cascade="all-delete-orphan">
<key column="SYSTEM_ID"/>
<element column="LCN" type="string" not-null="true"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
List list = session.find("select new DataModuleInfo(dm.dmc, dm.type, elements(dm.items)) from DataModuleInfo dm");
Full stack trace of any exception that occurs:Code:
Caused by: net.sf.hibernate.PropertyNotFoundException: no appropriate constructor in class: com.caliari.nova.ietm.DataModuleInfo
at net.sf.hibernate.util.ReflectHelper.getConstructor(ReflectHelper.java:200)
at net.sf.hibernate.hql.QueryTranslator.renderSQL(QueryTranslator.java:552)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:155)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1561)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1532)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1520)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at com.caliari.util.persistence.PersistentSession.find(PersistentSession.java:86)
... 1 more
Name and version of the database you are using: Oracle 9
iCiao,
I have tried to use projection to instantiate a DataModuleInfo passing a collection to his constructor but ReflectHelper.getConstructor for elements(dm.items) (a collection of ItemInfo) search for a constructor that require only one instance of ItemInfo:
Code:
DataModuleInfo(String, char, ItemInfo)
instead of
Code:
DataModuleInfo(String, char, ItemInfo[])
I have tried other types instead of ItemInfo[] but debugging Hibernate I see that he require only ItemInfo.
Can someone help me? Is possible using collections in dynamic instantiation?