1
這似乎有很多問題,但沒有解決我的問題。使用Uuid代休眠
我想使用休眠註釋來生成UUID。
我的註解是低於...
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid")
@Column(name = "uuid", unique = true)
public UUID getUuid() {
return uuid;
}
我在我的pom.xml使用MySQL 5.2和Hibernate 3.5.6,如下圖所示...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
當我開始應用程序中,我得到以下錯誤...
ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table players (uuid tinyblob not null unique, espnid integer, espnUrl varchar(255), firstname varchar(255), lastname varchar(255), primary key (uuid))
ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - BLOB/TEXT column 'uuid' used in key specification without a key length
什麼是正確的註釋?我是否使用不正確的休眠版本?我是否在MySQL中使用了不正確的東西?
我的方言細節如下...
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
</beans:prop>
<beans:prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory
</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
<beans:prop key="hibernate.hbm2ddl.auto">create</beans:prop>
</beans:props>
</beans:property>
的錯誤意味着未指定長度,但如果我進入這個@Column沒有什麼變化。
由於hibernate-annotations只有在那時纔會使用舊版本的hibernate,如果這是現在的死回購,我將轉移到更高版本。
啊,我也這麼認爲,但是從Hibernate 3.6我認爲他們支持UUID數據類型?剛剛閱讀http://stackoverflow.com/questions/4346898/problems-mapping-uuid-in-jpa-hibernate – david99world
你在你的問題中指定休眠版本3.5。是的,這個鏈接的問題適用於hiberante 3.6 – dcernahoschi
啊,對不起我會編輯我的問題,如果我需要更新hibernate我會很樂意,但從查看maven倉庫註釋倉庫只持續到3.5 .6,現在是一個死回購? – david99world