سؤال

أحاول استخدام قاعدة بيانات موجودة مع Grails. يبدأ DataSource.groovy بهذا:

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. هل هذا corect؟

أخطط لتغيير قاعدة البيانات لاستخدام المعرف بدلاً من regexp_id. لكن لا ينبغي أن يكون لدي أيضا.

أيه أفكار؟

شكرًا!

هل كانت مفيدة؟

المحلول

Hmm, you might have gotten away with naming the Integer field id, then just putting the @Column annotation to point that property at the regexp_id column in the table.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top