Grails에서 기존 데이터베이스를 사용하려고합니다. 내 DataSource.groovy에이 시작 다음과 같이Grails Ignoring @Id Annotation
import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration
dataSource {
configClass = GrailsAnnotationConfiguration.class
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "12345"
}
내 클래스가 주석 한 :
@Entity
@Table(name = "regexpression", catalog = "tigger")
@SuppressWarnings("serial")
public class Regexpression implements Serializable {
/**
* Attribute regexpId.
*/
private Integer regexpId;
. . .
/**
* <p>
* </p>
* @return regexpId
*/
@Basic
@Id
@GeneratedValue
@Column(name = "regexp_id")
public Integer getRegexpId() {
return regexpId;
}
. . .
나는 다음과 같은 오류 얻을 생성 된 코드를 실행하면 : 그래서
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error evaluating expression [regexpressionInstance.id] on line [40]: groovy.lang.MissingPropertyException: No such property: id for class: org.maflt.flashlit.pojo.Regexpression
을 Grails는 regexp_id의 @Id 주석을 무시하고있는 것 같습니다. 그 핵심입니까?
regexp_id 대신 id를 사용하도록 데이터베이스를 변경할 계획입니다. 그러나 나는 그렇게해서는 안된다.
아이디어가 있으십니까?
감사합니다.
기본 키를 id로 변경하고 pojo를 regenned하고 grails 앱을 regenned하면 이제 작동합니다. 그러나 나는 모든 핵심 필드를 id라고 그냥 부르는 생각을 좋아하지 않습니다. 게다가 나는 모든 외래 키 제약 조건을 삭제하고 작성했습니다. 그래서 저는 여전히 해결책을 찾고 있습니다. –