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