Spring Roo托管实体:禁用乐观锁定

时间:2013-05-03 10:02:36

标签: java spring hibernate spring-roo

有人知道如何在Spring Roo托管实体中禁用乐观锁定吗? 我生成的实体注释如下:

@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class CoolDomain {
}

然而,当我启动应用程序时,它无法连接实体经理说:

Caused by: org.hibernate.HibernateException: Missing column: version in COOL_DOMAIN
    at org.hibernate.mapping.Table.validateColumns(Table.java:369)
    at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1275)
    at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:506)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
    ... 51 more 

1 个答案:

答案 0 :(得分:0)

为避免版本检查,我将versionField=""属性添加到@RooJpaActiveRecord注释。 这解决了这个问题:

@RooJavaBean
@RooToString
@RooJpaActiveRecord(versionField="")
public class CoolDomain {
}