Grails 2.5.0 null id为持久化对象

时间:2015-06-22 09:59:27

标签: grails gorm

当我尝试保存receiveTransaction时,我得到了这个异常

  

引起:org.postgresql.util.PSQLException:错误:“letter_id”列中的空值违反非空约束     细节:失败的行包含(5,0,RECEIVE,67,nraed,2015-06-22 12:56:17.111,null,ملوخية,3,null,1,f,1,DONE,ps.police.parchive.LetterTransaction , 空值)。       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)       at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:560)       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363)       ... 9更多

Letter hasMany letterTransaction

LetterTransaction Domain:

$('#Amount').keyup(function() {
   var price = parseFloat($('#price').text());
   $('#result').text(price * parseFloat($(this).val()));
});

}

控制器中的

class LetterTransaction {
ActionEnum action
Date dateTime
Party party
ArchiveStructure archiveStructure
Boolean reviewed = Boolean.FALSE
TransactionStatus status=TransactionStatus.PENDING
String notes
Long sequence
LetterTransaction relatedTransaction

RelatedLetter relatedLetter
List signs          = new ArrayList()
List reviewLogs     = new ArrayList()
List divisionPathes = new ArrayList()
List targets = new ArrayList()
String createdBy
boolean deleted

static transients = ['deleted']

static belongsTo = [letter:Letter]
static hasMany = [
        targets:Party,
        // related letters in case this letter is related to other letters (Attachments)

        // actions have bean specified by organization manager التاشيرات
        signs:Sign,
        // all reviewing actions have bean taken for this letter
        reviewLogs:ReviewLog,
        // this devision path describes where scans have bean saved, according the ArchiveStructure for this letter
        divisionPathes:DivisionPath
]

1 个答案:

答案 0 :(得分:0)

我不知道原因是我通过在添加letterTransaction而不是保存receiveTransaction之后保存字母实例来修复此问题。这太奇怪了。