spring+Hibernate執行時出錯,各位大哥幫忙啊!!!!!!!!!!!!!!!!!!!
我想得到表T_Bidding_QuestAndAnswerAnnex的全部欄位、表T_Base_Project部分欄位 內容
(我用了引用project物件,"many-to-one";而事實上我只需要project.projectname一個欄位,不知道該怎麼做,只好
包函它的全部內容了!),在執行:list("AHPTC-2004-107", 174) 測試時出錯了?????????????
LOG資訊如下:
--------------->1
Hibernate: select top 10 questandan0_.id as id0_, project1_.projectid as projectid1_, questandan0_.projectid as projectid0_, questandan0_.enterpriseid as enterpri3_0_, questandan0_.filename as filename0_, questandan0_.memo as memo0_, questandan0_.state as state0_, questandan0_.oldfilename as oldfilen7_0_, questandan0_.uploadtime as uploadtime0_, project1_.projectcode as projectc2_1_, project1_.projectname as projectn3_1_, project1_.projectcontent as projectc4_1_, project1_.enterpriseid as enterpri5_1_, project1_.employeeid as employeeid1_, project1_.projecttype as projectt7_1_, project1_.projectmode as projectm8_1_, project1_.chargemode as chargemode1_, project1_.sum as sum1_, project1_.biddingdate as bidding11_1_, project1_.biddingtime as bidding12_1_, project1_.projectintroduce as project13_1_, project1_.state as state1_, project1_.loginname as loginname1_, project1_.password as password1_, project1_.memo as memo1_, project1_.recorderdate as recorde18_1_, project1_.isdispartment as isdispa19_1_ from T_Bidding_QuestAndAnswerAnnex questandan0_ inner join T_Base_Project project1_ on questandan0_.projectid=project1_.projectid where (project1_.projectcode=? ) order by questandan0_.projectid
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.ahptc.bo.Project.setSum
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:212)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2199)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.ahptc.service.dao.hibernate.QuestAnnexHibernateDAO$1.doInHibernate(QuestAnnexHibernateDAO.java:64)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:170)
at com.ahptc.service.dao.hibernate.QuestAnnexHibernateDAO.list(QuestAnnexHibernateDAO.java:43)
at com.ahptc.action.DownQuestionAction.execute(DownQuestionAction.java:57)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at com.ahptc.tp.servlet.EncodeFilter.doFilter(EncodeFilter.java:61)
..............................
相關程式碼貼出如下:
這是執行的程式碼QuestAnnexHibernateDAO:
public List list(final String projectCode, final int enterpriseId) {
sb.append("from bo.QuestAndAnswerAnnex annex ");
sb.append("join annex.project as project ");
sb.append("where annex.project.projectcode = :projectcode ");
sb.append("order by annex.projectid");
Query query = session.createQuery(sb.toString());
query.setString("projectcode", projectCode);
System.out.println(" --------------->1 "+);
List list=null;
try{
list = query.list();
}catch(Exception e){
e.printStackTrace();
}
//session.close();
System.out.println("--------------->>>>>> "+list.size());
return list;
}
});
}
以下是spring配置檔案applicationContext-hibernate.xml:
...
<property name="mappingResources">
<list>
<value>bo/QuestAndAnswerAnnex.hbm.xml</value>
<value>bo/Project.hbm.xml</value>
</list>
</property>
...
<bean id="questAnnexDAO" class="dao.hibernate.QuestAnnexHibernateDAO">
<property name="sessionFactory"><ref local="mySessionFactory"/></property>
</bean>
以下是QuestAndAnswerAnnex.java檔案內容:
public class QuestAndAnswerAnnex implements Serializable {
...
private Project project;
...
}
以下是Project.java檔案內容:
public class Project implements Serializable {
...
private Set questAnnex= new HashSet();
...
}
以下是QuestAndAnswerAnnex.hbm.xml檔案內容:
<hibernate-mapping>
<class name="bo.QuestAndAnswerAnnex" table="T_Bidding_QuestAndAnswerAnnex">
<composite-id >
<key-property name="projectid" column="projectid" type="integer" length="4"/>
<key-property name="enterpriseid" column="enterpriseid" type="integer" length="4"/>
</composite-id>
<property name="filename" column="filename" type="string" length="100"/>
...
<property name="id" column="id" type="integer" length="4" not-null="true"/>
<many-to-one
name="project"
class="bo.Project"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="projectid"
/>
</class>
</hibernate-mapping>
以下是Project.hbm.xml檔案內容:
<hibernate-mapping>
<class name="bo.Project" table="T_Base_Project">
<id name="projectid" column="projectid" type="integer" length="4">
<generator class="uuid.hex"/>
</id>
<property name="projectcode" column="projectcode" type="string" length="100"/>
<property name="projectname" column="projectname" type="string" length="500" not-null="true"/>
<property name="enterpriseid" column="enterpriseid" type="string" length="500"/>
<property name="projectintroduce" column="projectintroduce" type="serializable"/> //type="serializable"此對應的是表中text型別
...
<set name="questAnnex" inverse="true" lazy="true" cascade="all">
<key column="projectid"/>
<one-to-many class="bo.QuestAndAnswerAnnex"/>
</set>
</class>
</hibernate-mapping>
(我用了引用project物件,"many-to-one";而事實上我只需要project.projectname一個欄位,不知道該怎麼做,只好
包函它的全部內容了!),在執行:list("AHPTC-2004-107", 174) 測試時出錯了?????????????
LOG資訊如下:
--------------->1
Hibernate: select top 10 questandan0_.id as id0_, project1_.projectid as projectid1_, questandan0_.projectid as projectid0_, questandan0_.enterpriseid as enterpri3_0_, questandan0_.filename as filename0_, questandan0_.memo as memo0_, questandan0_.state as state0_, questandan0_.oldfilename as oldfilen7_0_, questandan0_.uploadtime as uploadtime0_, project1_.projectcode as projectc2_1_, project1_.projectname as projectn3_1_, project1_.projectcontent as projectc4_1_, project1_.enterpriseid as enterpri5_1_, project1_.employeeid as employeeid1_, project1_.projecttype as projectt7_1_, project1_.projectmode as projectm8_1_, project1_.chargemode as chargemode1_, project1_.sum as sum1_, project1_.biddingdate as bidding11_1_, project1_.biddingtime as bidding12_1_, project1_.projectintroduce as project13_1_, project1_.state as state1_, project1_.loginname as loginname1_, project1_.password as password1_, project1_.memo as memo1_, project1_.recorderdate as recorde18_1_, project1_.isdispartment as isdispa19_1_ from T_Bidding_QuestAndAnswerAnnex questandan0_ inner join T_Base_Project project1_ on questandan0_.projectid=project1_.projectid where (project1_.projectcode=? ) order by questandan0_.projectid
net.sf.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of com.ahptc.bo.Project.setSum
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:212)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2199)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1536)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.ahptc.service.dao.hibernate.QuestAnnexHibernateDAO$1.doInHibernate(QuestAnnexHibernateDAO.java:64)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:150)
at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:170)
at com.ahptc.service.dao.hibernate.QuestAnnexHibernateDAO.list(QuestAnnexHibernateDAO.java:43)
at com.ahptc.action.DownQuestionAction.execute(DownQuestionAction.java:57)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at com.ahptc.tp.servlet.EncodeFilter.doFilter(EncodeFilter.java:61)
..............................
相關程式碼貼出如下:
這是執行的程式碼QuestAnnexHibernateDAO:
public List list(final String projectCode, final int enterpriseId) {
sb.append("from bo.QuestAndAnswerAnnex annex ");
sb.append("join annex.project as project ");
sb.append("where annex.project.projectcode = :projectcode ");
sb.append("order by annex.projectid");
Query query = session.createQuery(sb.toString());
query.setString("projectcode", projectCode);
System.out.println(" --------------->1 "+);
List list=null;
try{
list = query.list();
}catch(Exception e){
e.printStackTrace();
}
//session.close();
System.out.println("--------------->>>>>> "+list.size());
return list;
}
});
}
以下是spring配置檔案applicationContext-hibernate.xml:
...
<property name="mappingResources">
<list>
<value>bo/QuestAndAnswerAnnex.hbm.xml</value>
<value>bo/Project.hbm.xml</value>
</list>
</property>
...
<bean id="questAnnexDAO" class="dao.hibernate.QuestAnnexHibernateDAO">
<property name="sessionFactory"><ref local="mySessionFactory"/></property>
</bean>
以下是QuestAndAnswerAnnex.java檔案內容:
public class QuestAndAnswerAnnex implements Serializable {
...
private Project project;
...
}
以下是Project.java檔案內容:
public class Project implements Serializable {
...
private Set questAnnex= new HashSet();
...
}
以下是QuestAndAnswerAnnex.hbm.xml檔案內容:
<hibernate-mapping>
<class name="bo.QuestAndAnswerAnnex" table="T_Bidding_QuestAndAnswerAnnex">
<composite-id >
<key-property name="projectid" column="projectid" type="integer" length="4"/>
<key-property name="enterpriseid" column="enterpriseid" type="integer" length="4"/>
</composite-id>
<property name="filename" column="filename" type="string" length="100"/>
...
<property name="id" column="id" type="integer" length="4" not-null="true"/>
<many-to-one
name="project"
class="bo.Project"
cascade="none"
outer-join="auto"
update="false"
insert="false"
column="projectid"
/>
</class>
</hibernate-mapping>
以下是Project.hbm.xml檔案內容:
<hibernate-mapping>
<class name="bo.Project" table="T_Base_Project">
<id name="projectid" column="projectid" type="integer" length="4">
<generator class="uuid.hex"/>
</id>
<property name="projectcode" column="projectcode" type="string" length="100"/>
<property name="projectname" column="projectname" type="string" length="500" not-null="true"/>
<property name="enterpriseid" column="enterpriseid" type="string" length="500"/>
<property name="projectintroduce" column="projectintroduce" type="serializable"/> //type="serializable"此對應的是表中text型別
...
<set name="questAnnex" inverse="true" lazy="true" cascade="all">
<key column="projectid"/>
<one-to-many class="bo.QuestAndAnswerAnnex"/>
</set>
</class>
</hibernate-mapping>
相關文章
- 救命啊!哪位大哥幫幫忙啊 程式出來很大的問題哦
- 在jbuilder下,jive出錯。各位幫忙呀!UI
- 各位大哥,jboss配置資料來源的問題,幫幫忙!
- 各位大哥,幫忙解決一下這個問題
- 請各位高手幫忙!
- 麻煩各位高手幫忙
- 本人初學JAVA請各位幫幫忙...Java
- 各位高手幫幫忙吧!servlet多執行緒問題,詳細內容請進!!!Servlet執行緒
- 奇怪!!奇怪!真是不可理解。哪位大哥幫幫忙。
- 求助:SimpleJdonFrameworkTest+JBOSS配置,執行出錯。banq老師幫忙看看Framework
- benq大哥,幫忙,請進入,謝謝!ENQ
- 各位高手請幫忙,不勝感激!!!!
- synchronized關鍵字問題?各位高手,幫幫忙!synchronized
- 釋出成功了,但客戶段呼叫有問題,幫幫忙啊
- 安裝出錯,請幫忙看看(轉)
- 幫我看看我的jmsBean,執行測試時出錯!Bean
- 幫幫忙吧!執行程式報錯:java.lang.verifyError行程JavaError
- 有關javaAPI,請各位高手幫忙,拜謝JavaAPI
- 急!!!!!!!!!jdon的SimpleJdonFrameworkTest例子不能在tomcat+jb下執行,請各位大俠幫忙FrameworkTomcat
- Ehcahe操作無效,希望各位能幫忙解決
- 實在是解決不了,請各位高手幫忙
- SPRING整合STRUCTS的小白問題 高手們幫幫忙啊SpringStruct
- 一個寫xml的問題,高手幫忙啊!XML
- JiveJdon執行後執行註冊的時候碰到的錯誤,請教各位?
- [求助] 在 Linux 下執行 web 自動化測試,pytest 報錯了,大家幫忙看看這是啥問題啊?LinuxWeb
- 關於petstore的最新版本? 請banq大哥幫忙
- jbuilder編譯jive出現的錯誤,高手幫忙!!UI編譯
- 請各位幫幫忙――怎樣在Jbuilder x中加入sql的驅動UISQL
- 各位幫忙解決一下一道題
- banq 老師幫忙啊 如何設定log4j???
- hibernate subclass map 父類到子類時轉換出錯(大家幫下忙)(3)
- hibernate subclass map 父類到子類時轉換出錯(大家幫下忙)(2)
- 求各位前輩幫忙看看連表查詢字首問題
- 請教關於jive原始碼,請各位高手幫忙 ,謝謝!!!原始碼
- 一個執行緒的問題。請大俠進來幫幫忙看看執行緒
- 安裝JPETSTORE出錯,請幫忙看看是哪出了問題.
- 安裝時提示錯誤,請高手幫忙解決一下
- 各位大哥,banq大哥請進,有關jdon版的安裝