Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate Grails休眠多对多问题_Hibernate_Grails_Instance - Fatal编程技术网

Hibernate Grails休眠多对多问题

Hibernate Grails休眠多对多问题,hibernate,grails,instance,Hibernate,Grails,Instance,我的域具有以下关系: class Offices { String officeLocation String officeName static belongsTo = Department static hasMany = [departments:Department, employees:Employee] } 当用户位于允许他们添加和删除位置的页面上时,根据用户选择多次加载模板即可完成此操作。当用户点击“添加位置”时,我需要确保实例保持不变。我在控制器中的功能: def add

我的域具有以下关系:

class Offices {

String officeLocation
String officeName

static belongsTo = Department
static hasMany = [departments:Department, employees:Employee]

}
当用户位于允许他们添加和删除位置的页面上时,根据用户选择多次加载模板即可完成此操作。当用户点击“添加位置”时,我需要确保实例保持不变。我在控制器中的功能:

def addLocation() {

def officesInstance = new Offices(officeLocation: params.officeLocation, officeName: params.officeName)

render template: "form" , model: [officesInstance: officesInstance]

}
查看代码:

<g:each var="entry" in="${departmentList}">

            <div class="control-group fieldcontain">
                <label class="bold" for="department">
                    <g:message code="department.locked.label" default="${entry.encodeAsHTML()}" />
                </label>
                <div class="controls form-field-align form-field-pad">
                    <g:checkBox name="department_${entry}" value="${officesInstance.value}" />
                </div>
            </div>

        </g:each>
|错误2015-02-27 12:51:52416[http-bio-8080-exec-7] 错误。GrailExceptionResolver-处理请求时发生断言失败:[POST]/myapp/Office/addLocation-参数:

办公地点:伦敦

formId:createForm

elementToReplace:elementToReplace

办公室名称:办公室名称

com.smool.Offices条目中的null id(发生异常后不要刷新会话)。跟踪如下: Office:com.myapp.Offices条目中的null id(发生异常后不要刷新会话) 直线法

->>  200 | doFilter  in grails.plugin.cache.web.filter.PageFragmentCachingFilter


您忘记保存OfficeInstance。保存(刷新:true)谢谢。。这就通过了保存问题,但我的复选框没有保持选中状态。。。更新如上如果您只是在复选框之外定义${OfficeInstance.value},那么${OfficeInstance.value}在gsp中返回什么?我想这就是它不起作用的原因,也就是说,这不是返回的复选框的实际值|没有,很抱歉,应该是OfficeInstance,即使我在添加其他位置时未选中,它仍保持选中状态
->>  200 | doFilter  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
63 | doFilter  in grails.plugin.cache.web.filter.AbstractFilter
53 | doFilter  in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
49 | doFilter  in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter
82 | doFilter  in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
745 | run       in java.lang.Thread