我在grails中有两个域类。一个叫做Book,另一个叫做Author。 我的Book类看起来像这样,
class Book {
String name
static constraints = {
name nullable:false
}
}
和我的作者班:
class Author {
String name
Book book1
Book book2
Book book3
static constraints = {
name nullable:false
book1 nullable:false
book2 nullable:true
book3 nullable:true
}
}
如果我创建了一本有两本书的作者,然后将其编辑成一本书,我收到了以下错误:
identifier of an instance of com.apps.Book was altered from 2 to null
如何解决?我正在使用grails 2.1.1和sql server 2008。
答案 0 :(得分:1)
尝试在更新方法中的行# Symfony deploy
export COMPOSER_HOME="$OPENSHIFT_DATA_DIR/.composer"
if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then
curl -s https://getcomposer.org/installer | php -- --install
dir=$OPENSHIFT_DATA_DIR
else
php $OPENSHIFT_DATA_DIR/composer.phar self-update
fi
cd $OPENSHIFT_REPO_DIR
php `find -name build_bootstrap.php`
.openshift/action-hooks: http://pastebin.com/iVBmvY4X
之前设置为null book2和book3属性,如下所示:
authorInstance.properties = params
答案 1 :(得分:0)
尝试使用' hasOne'在作者类中:
class Author {
String name
Book book1, book2, book3
static hasOne = [ book1:Book, book2:Book, book3:Book ]
}