nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z

來源:互聯網
上載者:User

使用spring + hibernate annotations的@OneToMany 一對多雙向關聯後出現異常: 
java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z 
出現這種異常通常是由於Myeclipse的javaee.jar 版本較低,與Hibernate等內建的JPA出現了衝突。 

網上一些處理方法是刪除項目裡的 刪除 建立web項目時內建的Javaee.jar,可是這樣帶來的後果是 httpServletRequest 等組件無法使用。 

直接用JDK1.6建立工程

<prop key="javax.persistence.validation.mode">none</prop>

<bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">   <property name="dataSource" ref="dataSource" /><property name="hibernateProperties"><props><prop key="javax.persistence.validation.mode">none</prop><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.format">${hibernate.format}</prop><!--  只要建立一個空的資料庫 DDL就能根據實體類自動產生資料庫表--><prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop></props></property>  <property name="packagesToScan">      <list>       <value>com.gaozhi.school.**.model</value><!-- 掃描註解方式的實體類,也就是model -->      </list>       </property>  </bean>


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.