0

我有 Grails(2.2.1) 项目,想用 Hibernate 创建简单的“模型”类

@Entity
@Table(name="User")
class User {

    static mapping = {
        datasource 'system'
    }

    @Id
    @GeneratedValue
    @Column(name="id")
    private Long userId;

    @Column(name="email", nullable=false)
    private String email;

    public User(){

    }

    @Transient
    public Long getUserId(){
        return this.userId;
    }

    @Transient
    public String getEmail(){
        return this.email;
    }

}

但我收到以下错误:

Caused by MappingException: Could not determine type for: org.springframework.validation.Errors, at table: user, for columns: [org.hibernate.mapping.Column(errors)]
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

当我删除所有休眠注释时,应用程序部署在服务器上,但表用户只有两个属性(id、版本)。

谢谢您的帮助 !

4

1 回答 1

0

将您的域类移动到grails-app/domain并将其更改为:

class User {
    String email

    static mapping = {
        datasource 'system'
    }

    static constraints = {
        email nullable: false
    }
}

11 行与 31 行。时髦的。

于 2013-09-11T16:10:18.847 回答