2010-11-15 53 views
1

我想在我的實體中使用jpa2特性@ElementCollection作爲字符串列表。我正在使用hibernate3-maven-plugin來執行hbm2ddl任務。在hibernate工具中支持@ElementCollection hbm2ddl

但是看起來插件使用的hibernate工具版本並不知道如何處理@ElementCollection註解,任何人都可以給我一些關於我需要使用哪些版本的hibernate工具的指針,這樣做並非如此。它應該只是一個指定正確版本的hibernate工具的例子嗎?

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>hibernate3-maven-plugin</artifactId> 
    <version>2.2</version> 
    <dependencies> 
<dependency> 
    <groupId>postgresql</groupId> 
    <artifactId>postgresql</artifactId> 
    <version>8.3-603.jdbc4</version> 
    </dependency> 
    <dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-tools</artifactId> 
    <version>3.2.4.GA</version> 
    <type>jar</type> 
    <scope>runtime</scope> 
</dependency> 

[INFO]跟蹤 org.hibernate.MappingException:可能 無法確定類型: java.util.List的,在表中:的MyStuff,用於 列: [有機.hibernate.mapping.Column(東西)]

由於

回答

4

我認爲你只是有一個版本與插件不匹配。 hibernate3-maven-plugin對Hibernate 3.3.1.GA有依賴性。

您可以嘗試忽略hibernate3-maven插件上的內容,並手動獲取正確的版本(3.5.3 Final可能工作)。

也許在字段而不是setter上設置註釋也可能有幫助。

+0

其中哪些解決了您的問題? – Eddie 2011-07-20 17:53:46

+0

很想看看如何解決這個問題! – 2011-11-19 18:58:34

+0

以下[鏈接](http://blog.flurdy.com/2010/07/orghibernatemappingexception-could-not.html)提供了讓插件按需要工作所需的步驟。 當我更新到最新版本的org.hibernate:hibernate-entitymanager到它工作的插件時,我正試圖改變插件中的hibernate工具版本。 – 2013-01-10 11:56:52