我有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
当我删除所有hibernate注释时,app部署在服务器上但是表User只有两个属性(id,version)。
感谢您的帮助!
答案 0 :(得分:0)
将您的域类移至grails-app/domain
并将其更改为:
class User {
String email
static mapping = {
datasource 'system'
}
static constraints = {
email nullable: false
}
}
11行与31行。 Groovy的。