我的域类有问题。每次我尝试插入条目时,都会出现此错误:
The column name "Sequence_No" was not found in this ResultSet.
这是我的域类:
class Record {
String firstName
String middleName
String lastName
String motherMaidenLastName
String motherMaidenMiddleName
Date birthDate
String examTypeCode
Date examinationDate
static constraints = {
firstName nullable:false, blank:false, maxSize: 50
middleName nullable:true, blank:true, maxSize: 50
lastName nullable:false, blank:false, maxSize: 50
motherMaidenLastName nullable:true, blank:true, maxSize: 50
motherMaidenMiddleName nullable:true, blank:true, maxSize: 50
birthDate nullable: false
examTypeCode nullable: false, maxSize: 4
examinationDate nullable: false
}
static mapping = {
datasource 'oevs'
table '`elig`'
id column: '`Sequence_No`'
firstName column: '`FirstName`'
middleName column: '`MiddleName`'
lastName column: '`LastName`'
motherMaidenLastName column: '`MotherMaidenLastName`'
motherMaidenMiddleName column: '`MotherMaidenMiddleName`'
birthDate column: '`Date_Birth`'
examTypeCode column: '`ExamType`'
examinationDate column: '`Date_Exam`'
}
}
但是我试图保存的条目被插入到数据库中,它只是抛出了那个错误。我正在使用 PostgreSQL。我被要求以这种方式命名列名。这就是为什么我需要在命名我的列时放置一个反引号字符,因为如果不这样做,PostgreSQL 会自动将其全部转换为小写字母。每次我删除 id 列中的反引号字符时,错误都不会出现,但显然列名已转换为小写。