-->
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: Problems with inheritnce Mapping
PostPosted: Thu Apr 28, 2005 11:29 am 
Newbie

Joined: Mon Jan 10, 2005 9:16 am
Posts: 18
I have the followin Problem with Hibernate 3. I try to load an inherited class by using the hibernate Session. But hibernate told me the Error - you can see in the stack trace. But i have generated the schema and inserted some colums befor. So I think the properties in the java Data classes are ok. The Class hirarchy is the following. BaseAssemply and ComplexAssembly is inherited from Assembly. Assembly has an reference to itself. It builds a tree structure. Could me please help anyone to solve the problem.

Best Reguards
Hibernate version:

Hibernate3

Mapping documents:

<?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>
<class name="de.tmobile.ebf.blizzard.assembly.hbm.DesignObjectImpl" table="Designobject">

<id name="id" type="long" column="id" unsaved-value="0">
<generator class="sequence">
<param name="sequence">id_sequence</param>
</generator>
</id>
<property name="buildDate" type="date"/>
<property name="type" type="string"/>

<joined-subclass name="de.tmobile.ebf.blizzard.assembly.hbm.AssemblyImpl" table="Assembly">
<key column="id"/>
<property name="buildDate" type="date"/>
<property name="type" type="string"/>

<one-to-one name="module" class="de.tmobile.ebf.blizzard.assembly.hbm.ModuleImpl" cascade="all"/>

<one-to-one name="superAssembly" class="de.tmobile.ebf.blizzard.assembly.hbm.ComplexAssemblyImpl" cascade="all"/>

<joined-subclass name="de.tmobile.ebf.blizzard.assembly.hbm.BaseAssemblyImpl" table="BaseAssembly">
<key column="id"/>

<one-to-one name="module" class="de.tmobile.ebf.blizzard.assembly.hbm.ModuleImpl" cascade="all"/>

<one-to-one name="superAssembly" class="de.tmobile.ebf.blizzard.assembly.hbm.ComplexAssemblyImpl" cascade="all"/>

<set name="componentsPriv" table="componentsPriv">
<key column="componentsPriv_id"/>
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.CompositePartImpl" />
</set>

<set name="componentsShar" table="componentsShar">
<key column="componentsShar_id"/>
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.CompositePartImpl" />
</set>

<property name="buildDate" type="date"/>
<property name="type" type="string"/>
</joined-subclass>

<joined-subclass name="de.tmobile.ebf.blizzard.assembly.hbm.ComplexAssemblyImpl" table="ComplexAssembly">
<key column="id"/>

<set name="subAssemblies" cascade="all">
<key column="assembly_id"/>
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.AssemblyImpl"/>
</set>

<one-to-one name="module" class="de.tmobile.ebf.blizzard.assembly.hbm.ModuleImpl" cascade="all"/>

<one-to-one name="superAssembly" class="de.tmobile.ebf.blizzard.assembly.hbm.ComplexAssemblyImpl" cascade="all"/>

<property name="buildDate" type="date"/>
<property name="type" type="string"/>
</joined-subclass>
</joined-subclass>

<joined-subclass name="de.tmobile.ebf.blizzard.assembly.hbm.ModuleImpl" table="Module">
<key column="id"/>

<set name="assembly" table="Assembly" cascade="all">
<key column="module_id"/>
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.AssemblyImpl"/>
</set>

<one-to-one name="manual" class="de.tmobile.ebf.blizzard.assembly.hbm.ManualImpl" cascade="all"/>

<one-to-one name="designRoot" class="de.tmobile.ebf.blizzard.assembly.hbm.ComplexAssemblyImpl" cascade="all"/>

<property name="buildDate" type="date"/>
<property name="type" type="string"/>
</joined-subclass>

<joined-subclass name="de.tmobile.ebf.blizzard.assembly.hbm.CompositePartImpl" table="CompositePart">
<key column="id"/>

<one-to-one name="documentation" class="de.tmobile.ebf.blizzard.assembly.hbm.DocumentImpl" cascade="all"/>

<one-to-one name="rootPart" class="de.tmobile.ebf.blizzard.assembly.hbm.AtomicPartImpl" cascade="all"/>

<set name="usedInPriv" table="usedInPriv">
<key column="usedInPriv_id"/>
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.BaseAssemblyImpl"/>
</set>

<set name="usedInShar" table="usedInShar">
<key column="usedInShar_id" />
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.BaseAssemblyImpl"/>
</set>

<set name="parts" table="AtomicPart" inverse="true">
<key column="part_id"/>
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.AtomicPartImpl"/>
</set>

<property name="buildDate" type="date"/>
<property name="type" type="string"/>
</joined-subclass>

<joined-subclass name="de.tmobile.ebf.blizzard.assembly.hbm.AtomicPartImpl" table="AtomicPart">
<key column="id"/>

<property name="docId"/>
<property name="x"/>
<property name="y"/>

<!--
<one-to-one name="partOf" class="de.tmobile.ebf.blizzard.assembly.hbm.CompositePartImpl" cascade="all"/>
-->

<set name="fromConnections" inverse="true" cascade="all">
<key column="fromCon"/>
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.ConnectionImpl"/>
</set>

<set name="toConnections" inverse="true" cascade="all">
<key column="toCon"/>
<one-to-many class="de.tmobile.ebf.blizzard.assembly.hbm.ConnectionImpl"/>
</set>

<many-to-one name="partOf" class="de.tmobile.ebf.blizzard.assembly.hbm.CompositePartImpl" column="compositeParts" cascade="all"/>
<!--
<many-to-one name="fromConnections" column="fromCon"/>

<many-to-one name="toConnections" column="toCon"/>
-->
<property name="buildDate" type="date"/>
<property name="type" type="string"/>
</joined-subclass>
</class>
</hibernate-mapping>



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

AssemblyImpl a = (AssemblyImpl) getSession().load(AssemblyImpl.class, new Long(2419));

Full stack trace of any exception that occurs:

[java] 8121 [2005-04-28 16:59:59,817] INFO org.hibernate.impl.SessionFactoryImpl - Checking 0 named queries
[java] Hibernate: select assemblyim0_.id as id0_, assemblyim0_1_.buildDate as buildDate0_0_, assemblyim0_1_.type as type0_0_, assemblyim0_.buildDate as buildDate1_0_, assemblyim0_.type as type1_0_, assemblyim0_2_.buildDate as buildDate2_0_, assemblyim0_2_.type as type2_0_, assemblyim0_3_.buildDate as buildDate3_0_, assemblyim0_3_.type as type3_0_, decode(assemblyim0_.id, assemblyim0_2_.id, 2, assemblyim0_3_.id, 3, 1) as clazz_0_ from Assembly assemblyim0_, Designobject assemblyim0_1_, BaseAssembly assemblyim0_2_, ComplexAssembly assemblyim0_3_ where assemblyim0_.id=assemblyim0_1_.id and assemblyim0_.id=assemblyim0_2_.id(+) and assemblyim0_.id=assemblyim0_3_.id(+) and assemblyim0_.id=?
[java] 8252 [2005-04-28 16:59:59,948] WARN org.hibernate.engine.PersistenceContext - Narrowing proxy to class de.tmobile.ebf.blizzard.assembly.hbm.ModuleImpl - this operation breaks ==
[java] 8382 [2005-04-28 17:00:00,078] ERROR org.hibernate.property.BasicPropertyAccessor - IllegalArgumentException in class: de.tmobile.ebf.blizzard.assembly.hbm.AssemblyImpl, setter method of property: module
[java] 8382 [2005-04-28 17:00:00,078] ERROR org.hibernate.property.BasicPropertyAccessor - expected type: de.tmobile.ebf.blizzard.assembly.hbm.ModuleImpl, actual value: de.tmobile.ebf.blizzard.assembly.hbm.BaseAssemblyImpl
[java] 8382 [2005-04-28 17:00:00,078] INFO org.hibernate.event.def.DefaultLoadEventListener - Error performing load command
[java] org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of de.tmobile.ebf.blizzard.assembly.hbm.AssemblyImpl.module
[java] at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:70)
[java] at org.hibernate.tuple.AbstractTuplizer.setPropertyValues(AbstractTuplizer.java:207)
[java] at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:171)
[java] at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2923)
[java] at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
[java] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:494)
[java] at org.hibernate.loader.Loader.doQuery(Loader.java:413)
[java] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208)
[java] at org.hibernate.loader.Loader.loadEntity(Loader.java:1278)
[java] at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:141)
[java] at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:126)
[java] at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2491)
[java] at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:386)
[java] at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:367)
[java] at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:166)
[java] at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140)
[java] at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:119)
[java] at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:593)
[java] at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
[java] at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
[java] at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
[java] at de.tmobile.ebf.blizzard.assembly.hbm.AssemblyImpl$$EnhancerByCGLIB$$eae6aa2c.getType(<generated>)
[java] at de.tmobile.ebf.blizzard.hbmclient.Query_Q4.testQuery_Q4(Query_Q4.java:72)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

Name and version of the database you are using:

Oracle 9i

The generated SQL (show_sql=true):



[schemaexport] drop table Assembly cascade constraints;
[schemaexport] drop table AtomicPart cascade constraints;
[schemaexport] drop table BaseAssembly cascade constraints;
[schemaexport] drop table CONNECTION cascade constraints;
[schemaexport] drop table ComplexAssembly cascade constraints;
[schemaexport] drop table CompositePart cascade constraints;
[schemaexport] drop table DOCUMENT cascade constraints;
[schemaexport] drop table Designobject cascade constraints;
[schemaexport] drop table MANUAL cascade constraints;
[schemaexport] drop table Module cascade constraints;
[schemaexport] drop sequence id_sequence;
[schemaexport] create table Assembly (
[schemaexport] id number(19,0) not null,
[schemaexport] buildDate date,
[schemaexport] type varchar2(255),
[schemaexport] assembly_id number(19,0),
[schemaexport] module_id number(19,0),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table AtomicPart (
[schemaexport] id number(19,0) not null,
[schemaexport] docId number(19,0),
[schemaexport] x number(19,0),
[schemaexport] y number(19,0),
[schemaexport] compositeParts number(19,0),
[schemaexport] buildDate date,
[schemaexport] type varchar2(255),
[schemaexport] part_id number(19,0),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table BaseAssembly (
[schemaexport] id number(19,0) not null,
[schemaexport] buildDate date,
[schemaexport] type varchar2(255),
[schemaexport] usedInPriv_id number(19,0),
[schemaexport] usedInShar_id number(19,0),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table CONNECTION (
[schemaexport] id number(19,0) not null,
[schemaexport] fromCon number(19,0),
[schemaexport] toCon number(19,0),
[schemaexport] type varchar2(255),
[schemaexport] length number(19,0),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table ComplexAssembly (
[schemaexport] id number(19,0) not null,
[schemaexport] buildDate date,
[schemaexport] type varchar2(255),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table CompositePart (
[schemaexport] id number(19,0) not null,
[schemaexport] buildDate date,
[schemaexport] type varchar2(255),
[schemaexport] componentsPriv_id number(19,0),
[schemaexport] componentsShar_id number(19,0),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table DOCUMENT (
[schemaexport] id number(19,0) not null,
[schemaexport] text varchar2(255),
[schemaexport] title varchar2(255),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table Designobject (
[schemaexport] id number(19,0) not null,
[schemaexport] buildDate date,
[schemaexport] type varchar2(255),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table MANUAL (
[schemaexport] id number(19,0) not null,
[schemaexport] title varchar2(255),
[schemaexport] text varchar2(255),
[schemaexport] blob blob,
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] create table Module (
[schemaexport] id number(19,0) not null,
[schemaexport] buildDate date,
[schemaexport] type varchar2(255),
[schemaexport] primary key (id)
[schemaexport] );
[schemaexport] alter table Assembly add constraint FKED98A20660340CAB foreign key (id) references Designobject;
[schemaexport] alter table Assembly add constraint FKED98A206D1D261ED foreign key (module_id) references Module;
[schemaexport] alter table Assembly add constraint FKED98A20674035DF7 foreign key (assembly_id) references ComplexAssembly;
[schemaexport] alter table AtomicPart add constraint FK7F177CDE193A7E6E foreign key (part_id) references CompositePart;
[schemaexport] alter table AtomicPart add constraint FK7F177CDE60340CAB foreign key (id) references Designobject;
[schemaexport] alter table AtomicPart add constraint FK7F177CDE43B9FE40 foreign key (compositeParts) references CompositePart;
[schemaexport] alter table BaseAssembly add constraint FK900A9BF7F6C384F4 foreign key (id) references Assembly;
[schemaexport] alter table BaseAssembly add constraint FK900A9BF74A2BBE50 foreign key (usedInPriv_id) references CompositePart;
[schemaexport] alter table BaseAssembly add constraint FK900A9BF7D75B6C59 foreign key (usedInShar_id) references CompositePart;
[schemaexport] alter table CONNECTION add constraint FKEEAE6ADE886D6B18 foreign key (toCon) references AtomicPart;
[schemaexport] alter table CONNECTION add constraint FKEEAE6ADE5E6A1F89 foreign key (fromCon) references AtomicPart;
[schemaexport] alter table ComplexAssembly add constraint FKFE3B0E96F6C384F4 foreign key (id) references Assembly;
[schemaexport] alter table CompositePart add constraint FK79BBDEFA4820A49F foreign key (componentsPriv_id) references BaseAssembly;
[schemaexport] alter table CompositePart add constraint FK79BBDEFA60340CAB foreign key (id) references Designobject;
[schemaexport] alter table CompositePart add constraint FK79BBDEFAD55052A8 foreign key (componentsShar_id) references BaseAssembly;
[schemaexport] alter table Module add constraint FK89B0928C60340CAB foreign key (id) references Designobject;
[schemaexport] create sequence id_sequence;
[schemaexport] 12007 [2005-04-28 17:10:49,892] INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
[schemaexport] 12017 [2005-04-28 17:10:49,902] INFO org.hibernate.connection.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:oracle:thin:@localhost:1521:hbdb
BUILD SUCCESSFUL
Total time: 13 seconds


Debug level Hibernate log excerpt:


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.