내 Record
도메인 클래스는 개체 다음과 같이저장 중첩는 다음과 같이
Record.groovy
Person person
Schedule schedule
String nameOfRecord
내 RecordService.groovy은 다음과 같습니다
def saveRecord (params) {
def personInstance = Person.get(params.record.person.id)
def scheduleInstance = Schedule.get(params.record.schedule.id)
def nameOfTheRecord = params.nameOfRecord
// At this point i want to save my Record. How can i do it
def rec = new Record(params)
rec.save(flush: true)
}
Person
및 Schedule
가 Record
테이블에 저장되지 않아요. 내가 어떻게 구할 수 있니?
나는 문제가 def rec = new Record(params)
함께 생각하고 내가 거기에 scheduleInstance
및 personInstance
을 저장하고 있지 않다. 어떻게 해결할 수 있을까요?
UPDATE는
<g:form controller="record" action="save">
<g:hiddenField name="record.person.id" value="${record.person.id}" />
<g:hiddenField name="record.schedule.id" value="${record.schedule.id}" />
... And other input field
나는 뷰 클래스에서 값을 받고, 실제로입니다. 내 코드를 업데이트했습니다. 따라서이 경우 값'params' 속성을 검색해야합니다. 그래서이 경우 나는'def saveRecord (Record record) {}'를 사용할 수 없다. – Illep
@Illep 죄송합니다, 귀하의 의견을 이해할 수 없습니다. –