-->
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.  [ 2 posts ] 
Author Message
 Post subject: Cannot get the inheritance-mapping to work (10.1.3 from doc)
PostPosted: Mon Jul 11, 2005 7:12 pm 
Beginner
Beginner

Joined: Wed Jan 19, 2005 6:07 am
Posts: 20
Hibernate V3.

I follow the sample in section 10.1.3 Table per subclass, using discriminatro, But can't get it to work properly.

When I copy the sample (omitting the key-attribute for the join) the parser complains that the key-attribute is missing.

When including the key this error occurs :
Quote:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/appContext.xml]: Initialization of bean failed; nested exception is java.util.NoSuchElementException: null
java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:426)
at org.hibernate.sql.InFragment.toFragmentString(InFragment.java:80)


When also including the mapping to the parent-table like this :

Code:
    <class name="no.song.b2b.clients.OrderProcessDAO" table="ordre_prosess">
        <id name="processId" column="prosess_id">
            <generator class="native" />
        </id>
        <discriminator column="prosess_type" type="string"/>
        <subclass name="no.song.b2b.clients.jara.JaraOrderProcessDAO" discriminator-value="Jara">
            <join table="ordre_prosess_jara">
               
                <key column="prosess_id"/>
                <many-to-one name="processId" column="prosess_id" class="no.song.b2b.clients.OrderProcessDAO"/>
            </join>
        </subclass>

    </class>


the error is like this :

Quote:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/appContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: no.song.b2b.clients.jara.JaraOrderProcessDAO column: prosess_id (should be mapped with insert="false" update="false")
org.hibernate.MappingException: Repeated column in mapping for entity: no.song.b2b.clients.jara.JaraOrderProcessDAO column: prosess_id (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:504)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:526)


Does anyone have the correct syntax for this mapping-scenario ?


Top
 Profile  
 
 Post subject: Figured this one out....
PostPosted: Tue Jul 12, 2005 6:45 am 
Beginner
Beginner

Joined: Wed Jan 19, 2005 6:07 am
Posts: 20
The problem was that I tried tu use another interface instead of an concrete class as my subclass-definition.


But when I did I got a new error...

The mapping :


Code:
    <class name="no.song.b2b.clients.OrderProcessDAO" table="ordre_prosess">
        <id name="processId" column="prosess_id" unsaved-value="-1">
            <generator class="increment" />
        </id>
        <discriminator column="prosess_type" type="string"/>
       
        <subclass name="no.song.b2b.clients.jara.JaraOrderProcessImpl" discriminator-value="Jara" >
             <join table="ordre_prosess_jara">
                 <key column="prosess_id"/>
                 <many-to-one name="processId" column="prosess_id" class="no.song.b2b.clients.OrderProcessDAO" update="false" insert="false" />
             </join>

         </subclass>
       
      </class>


The code :
Code:
        OrderProcess prosess = new JaraOrderProcessImpl();
        dao.saveOrUpdate(prosess);


The error :
Quote:
org.springframework.orm.hibernate3.HibernateSystemException: instance not of expected entity type: no.song.b2b.clients.OrderProcessDAO; nested exception is org.hibernate.HibernateException: instance not of expected entity type: no.song.b2b.clients.OrderProcessDAO
org.hibernate.HibernateException: instance not of expected entity type: no.song.b2b.clients.OrderProcessDAO
at org.hibernate.persister.entity.BasicEntityPersister.getSubclassEntityPersister(BasicEntityPersister.java:2986)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1089)


The class-structure is like this:

Two 'master interfaces' OrderProcess and OrderProcessDAO, two interfaces extending those : JaraOrderProcess and JaraOrderProcessDAO,
and the class implementing the two latter : JaraOrderProcessImpl.



The concrete class does only implement the master-DAO-interface via inheritance, but shouldn't this be allowed ??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.