Frage

Ich versuche, eine vorhandene Datenbank mit Grails zu verwenden. Meine DataSource.Groovy beginnt damit:

import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration
dataSource {
    configClass = GrailsAnnotationConfiguration.class
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    username = "root"
    password = "12345"

}

Ich habe meine Klasse wie folgt kommentiert:

@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;
    }
        . . . 

Wenn ich den generierten Code ausführe, erhalte ich den folgenden Fehler:

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

Es scheint also, dass Grails die @ID -Annotation auf regexp_id ignoriert. Ist das ein Core?

Ich habe vor, die Datenbank für die Verwendung von ID anstelle von regexp_id zu ändern. Aber ich hätte es auch nicht haben.

Irgendwelche Ideen?

Vielen Dank!

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top