hibernate subclass map 父類到子類時轉換出錯(大家幫下忙)(2)
-------------------------------------------------------------------
hibernate配置檔案:
<meta attribute="class-description">貸前調查主表</meta>
<id name="Id" type="java.lang.Long">
<meta attribute="field-description">id</meta>
<column name="ID" not-null="true" sql-type="bigint" />
<generator class="assigned" />
</id>
<discriminator column="Class" type="string" length="20"></discriminator>
<property name="type" not-null="false" type="string">
<meta attribute="field-description">貸前的型別</meta>
<column name="TYPE" not-null="false" sql-type="varchar(3)" />
</property>
<property name="typeName" not-null="false" type="string">
<meta attribute="field-description">貸前的名稱</meta>
<column name="TYPE_NAME" not-null="false"
sql-type="varchar(100)" />
</property>
...................
..................
</class>
</hibernate-mapping>
子類檔案:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.skyon.mica.frontage.entity">
<subclass name="CreditInquiryBulletin" extends="CreditInquiry"
discriminator-value="bulletin">
<map name="properties" table="CREDIT_INQUIRY_BULLETIN" cascade="all,delete-orphan" lazy="false">
<meta attribute="field-description">貸前調查從表_貸款調查報告</meta>
<key column="CREDIT_INQUIRY_ID" not-null="true" />
<map-key column="NAME" type="string" length="100" />
<element type="variable">
<column name="FIElD_TYPE"/>
<column name="VALUE" />
</element>
</map>
<join table="CREDIT_INQUIRY" fetch="select">
<key column="ID"/>
</join>
</subclass>
</hibernate-mapping>
說明這裡的子類是多個的..如以下,表結構是一樣的,只是數量量太大,所以按業務來分子表
<?xml version="1.0" encoding="GB2312" standalone="no"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.skyon.mica.frontage.entity">
<subclass name="CreditInquiryIndividualCustomer"
extends="CreditInquiry" discriminator-value="individualCustomer">
<map name="properties" table="CREDIT_INQUIRY_INDIVIDUAL_CUSTOMER" cascade="all,delete-orphan" lazy="false">
<meta attribute="field-description">貸前調查從表_對私客戶</meta>
<key column="CREDIT_INQUIRY_ID" not-null="true" />
<map-key column="NAME" type="string" length="100" />
<element type="variable">
<column name="FIElD_TYPE"/>
<column name="VALUE" />
</element>
</map>
<join table="CREDIT_INQUIRY_INDIVIDUAL_CUSTOMER_RELATING" fetch="select">
<key column="CREDIT_INQUIRY_ID"/>
</join>
</subclass>
</hibernate-mapping>
共七張相同的表
程式:
/**
* 根據一個id去得到子表的明細
* @return
*/
public String getCreditInquiryInfo() {
java.lang.Long id=creditInquiry.getId();
String type=creditInquiry.getType();
creditInquiry=creditInquiryManager.getCreditInquiry(id);
creditInquiry.getType();
if (id!=null && type!=null && !id.equals("") && !type.equals("")) {
this.returnTypeDetail(id,type);
//這裡出錯 /*CreditInquiryIndividualCustomer creditInquiryIndividualCustomer=new CreditInquiryIndividualCustomer();
creditInquiryIndividualCustomer=(CreditInquiryIndividualCustomer)creditInquiryManager.getCreditInquiry(id);*/
String page=this.returnTypePage(type);
if (page!=null) {
return page;
}
}
this.addActionError(this.getText("creditInquiry.noDetail"));
return ERROR;
}
錯誤:
java.lang.ClassCastException: com.skyon.mica.frontage.entity.CreditInquiry$$EnhancerByCGLIB$$67a4c7a6
繼三
hibernate配置檔案:
<meta attribute="class-description">貸前調查主表</meta>
<id name="Id" type="java.lang.Long">
<meta attribute="field-description">id</meta>
<column name="ID" not-null="true" sql-type="bigint" />
<generator class="assigned" />
</id>
<discriminator column="Class" type="string" length="20"></discriminator>
<property name="type" not-null="false" type="string">
<meta attribute="field-description">貸前的型別</meta>
<column name="TYPE" not-null="false" sql-type="varchar(3)" />
</property>
<property name="typeName" not-null="false" type="string">
<meta attribute="field-description">貸前的名稱</meta>
<column name="TYPE_NAME" not-null="false"
sql-type="varchar(100)" />
</property>
...................
..................
</class>
</hibernate-mapping>
子類檔案:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.skyon.mica.frontage.entity">
<subclass name="CreditInquiryBulletin" extends="CreditInquiry"
discriminator-value="bulletin">
<map name="properties" table="CREDIT_INQUIRY_BULLETIN" cascade="all,delete-orphan" lazy="false">
<meta attribute="field-description">貸前調查從表_貸款調查報告</meta>
<key column="CREDIT_INQUIRY_ID" not-null="true" />
<map-key column="NAME" type="string" length="100" />
<element type="variable">
<column name="FIElD_TYPE"/>
<column name="VALUE" />
</element>
</map>
<join table="CREDIT_INQUIRY" fetch="select">
<key column="ID"/>
</join>
</subclass>
</hibernate-mapping>
說明這裡的子類是多個的..如以下,表結構是一樣的,只是數量量太大,所以按業務來分子表
<?xml version="1.0" encoding="GB2312" standalone="no"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.skyon.mica.frontage.entity">
<subclass name="CreditInquiryIndividualCustomer"
extends="CreditInquiry" discriminator-value="individualCustomer">
<map name="properties" table="CREDIT_INQUIRY_INDIVIDUAL_CUSTOMER" cascade="all,delete-orphan" lazy="false">
<meta attribute="field-description">貸前調查從表_對私客戶</meta>
<key column="CREDIT_INQUIRY_ID" not-null="true" />
<map-key column="NAME" type="string" length="100" />
<element type="variable">
<column name="FIElD_TYPE"/>
<column name="VALUE" />
</element>
</map>
<join table="CREDIT_INQUIRY_INDIVIDUAL_CUSTOMER_RELATING" fetch="select">
<key column="CREDIT_INQUIRY_ID"/>
</join>
</subclass>
</hibernate-mapping>
共七張相同的表
程式:
/**
* 根據一個id去得到子表的明細
* @return
*/
public String getCreditInquiryInfo() {
java.lang.Long id=creditInquiry.getId();
String type=creditInquiry.getType();
creditInquiry=creditInquiryManager.getCreditInquiry(id);
creditInquiry.getType();
if (id!=null && type!=null && !id.equals("") && !type.equals("")) {
this.returnTypeDetail(id,type);
//這裡出錯 /*CreditInquiryIndividualCustomer creditInquiryIndividualCustomer=new CreditInquiryIndividualCustomer();
creditInquiryIndividualCustomer=(CreditInquiryIndividualCustomer)creditInquiryManager.getCreditInquiry(id);*/
String page=this.returnTypePage(type);
if (page!=null) {
return page;
}
}
this.addActionError(this.getText("creditInquiry.noDetail"));
return ERROR;
}
錯誤:
java.lang.ClassCastException: com.skyon.mica.frontage.entity.CreditInquiry$$EnhancerByCGLIB$$67a4c7a6
繼三
相關文章
- hibernate subclass map 父類到子類時轉換出錯(大家幫下忙)(3)
- 父類和子類之間的轉換問題
- spring+Hibernate執行時出錯,各位大哥幫忙啊!!!!!!!!!!!!!!!!!!!Spring
- 安裝出錯,請幫忙看看(轉)
- 類的繼承_子類繼承父類繼承
- C# 繼承 子類(派生類) 父類(基類)C#繼承
- 在jbuilder下,jive出錯。各位幫忙呀!UI
- 鏈式-父類中返回子類物件物件
- 子父類中函式函式
- 我的第一個entity Ejb就出錯!大家幫幫忙
- java中父類宣告子類例項化Java
- 子類繼承父類(父類和子類裡:塊、靜態塊、構造和方法覆寫)之間呼叫順序繼承
- php5.3.3呼叫https的wsdl,出現錯誤,請大家幫忙看看PHPHTTP
- 子父類中成員變數變數
- 父類和子類的建構函式問題函式
- Java 中建立子類物件會建立父類物件麼?Java物件
- 京東獲得jd商品分類API介面(父分類、根分類、子分類)API
- 如何理解Python3中的子類和父類?Python
- java中多型的理解——父類引用指向子類物件Java多型物件
- [短文速度-4] new子類是否會例項化父類
- 子類重寫父類的方法@Override的快捷鍵IDE
- 子類繼承父類的建構函式(方法)嗎?繼承函式
- 關於CSS中的定位使用子絕父相(子類絕對位置和父類相對位置)CSS
- 大家幫幫忙,看看這個SQL怎麼寫!SQL
- 用URLClassLoader無法實現重新載入類,幫幫忙
- Java子類和父類的初始化執行順序Java
- C++父類指標指向子類物件的實現原理C++指標物件
- 安裝時提示錯誤,請高手幫忙解決一下
- Map集合中的具體子類TreeMap
- 我在安裝第一個軟體mplayer時遇到困難,請大家幫忙!(轉)
- jsp+javaBean+hibernate 執行時報錯,大家幫著看看!JSJavaBean
- Java常用時間格式轉換工具類Java
- 從子類化到Typeclass
- 一道面試題:大家幫忙解決面試題
- jsp與xmlhttp在IE5.0中出現亂碼!請大家幫幫忙!JSXMLHTTP
- 基類與派生類的轉換
- C#介面、抽象類、普通類和繼承(子類與父類)都有其特定的用途和場景C#抽象繼承
- 急不理解的問題,大家幫幫忙,關於jive