-->
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: joined-subclass dilema
PostPosted: Fri Mar 03, 2006 2:40 pm 
Newbie

Joined: Wed Feb 22, 2006 11:56 am
Posts: 4
Location: Campinas, Sãop Paulo, Brazil
I have three subclasses of the paramter class:
SubprojectParameter
BuildTypeParameter
ScriptParameter

when I load some BuildTypeParameters instances, and then I load some ScriptParameters, it raises WrongClassException, because the ID, at the Parameter class, whas already loaded with the BuildTypeParameter...

anyone know a way to solve this problem?

Hibernate version:
2.1.6
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.cpqd.wifa.Parameter"
        table="PARAMETRO"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
        optimistic-lock="version"
    >

        <id
            name="id"
            column="ID_PARAM"
            type="java.lang.Integer"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-Parameter.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <property
            name="defaultValue"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="VLR_DEFAULT"
            not-null="false"
        />

        <property
            name="name"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="NOME_PARAM"
            not-null="true"
        />

        <property
            name="type"
            type="char"
            update="true"
            insert="true"
            access="property"
            column="TIPO_PARAM"
            not-null="false"
        />

        <property
            name="userEdit"
            type="boolean"
            update="true"
            insert="true"
            access="property"
            column="USUARIO_EDIT"
            not-null="true"
        />

        <property
            name="label"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="LABEL_PARAM"
            not-null="true"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Parameter.xml
            containing the additional properties and place it in your merge dir.
        -->

        <joined-subclass
            name="com.cpqd.wifa.SubprojectParameter"
            table="PARAM_SUBPROJ"
            dynamic-update="false"
            dynamic-insert="false"
        >
        <key
            column="ID_PARAM"
        />

        <many-to-one
            name="subproject"
            class="com.cpqd.wifa.Subproject"
            cascade="save-update"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="ID_SUBPRJ"
        />

        <property
            name="value"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="VLR_PARAM"
        />

        </joined-subclass>
        <joined-subclass
            name="com.cpqd.wifa.BuildTypeParameter"
            table="PARAM_ATIVIDADE"
            dynamic-update="false"
            dynamic-insert="false"
        >
        <key
            column="ID_PARAM"
        />

        <many-to-one
            name="buildType"
            class="com.cpqd.wifa.BuildType"
            cascade="save-update"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="ID_ATIVIDADE"
        />

        <property
            name="value"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="VLR_PARAM"
        />

        </joined-subclass>
        <joined-subclass
            name="com.cpqd.wifa.ScriptParameter"
            table="PARAM_SCRIPTS"
            dynamic-update="false"
            dynamic-insert="false"
        >
        <key
            column="ID_PARAM"
        />
        <property
            name="opcional"
            type="boolean"
            update="true"
            insert="true"
            access="property"
            column="OPCIONAL"
            not-null="false"
        />

        <many-to-one
            name="script"
            class="com.cpqd.wifa.Script"
            cascade="save-update"
            outer-join="auto"
            update="true"
            insert="true"
            access="property"
            column="ID_SCRIPT"
        />

        <property
            name="value"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="VLR_PARAM"
            not-null="false"
        />

        <property
            name="order"
            type="java.lang.Integer"
            update="true"
            insert="true"
            access="property"
            column="ORDEM"
            not-null="false"
        />

        <property
            name="signature"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="ASSINATURA"
            not-null="false"
        />

        </joined-subclass>

    </class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
Code:
net.sf.hibernate.WrongClassException: Object with id: 1 was not of the specified subclass: com.cpqd.wifa.ScriptParameter (loaded object was of wrong class)
   net.sf.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:535)
   net.sf.hibernate.loader.Loader.getRow(Loader.java:502)
   net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:218)
   net.sf.hibernate.loader.Loader.doQuery(Loader.java:285)
   net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
   net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
   net.sf.hibernate.loader.Loader.list(Loader.java:1054)
   net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
   net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
   net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
   com.cpqd.wifa.dao.HibernateScriptParameterDAO.findByScript(HibernateScriptParameterDAO.java:49)
   com.cpqd.wifa.builder.ScriptMounter.getParamsFromStepScript(ScriptMounter.java:196)
   com.cpqd.wifa.builder.ScriptMounter.mountScripts(ScriptMounter.java:89)
   com.cpqd.wifa.actions.MountScriptAction.execute(MountScriptAction.java:70)
   org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
   org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
   org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
   org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   com.cpqd.wifa.HibernateFilter.doFilter(HibernateFilter.java:24)

Name and version of the database you are using:
MySQL 4.1

_________________
Simplify your J2EE development with Mentawai - XML-Free framework.

Because we want save Java from RoR :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 9:31 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
wrong forum

_________________
Emmanuel


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.