저는 grails 초보자입니다. 그리고 나는 grails 튜토리얼을보고 있습니다. 새로운 사용자로서, grails 쉘은 나를 위해 정말 유용한 도구이지만, 클래스와 객체를 보는 방법을 알아낼 수 없습니다. 여기에 내가 시도하고있는 작업은 다음과 같습니다Grails shell은 도메인 객체를 보지 못합니다.
% grails create-app test
% cd test
% grails create-domain-class com.test.TestObj
% grails shell
groovy:000> new TestObj()
ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, groovysh_evaluate: 2: unable to resolve class TestObj
내가 Grails의 쉘은 컨트롤러, 서비스 및 도메인의 모든 개체를 볼 수 있다는 인상이었다. 이게 뭐야? 여기서 다른 것을해야합니까? 내가 잘못
groovy:000> foo = new com.test.TestObj();
===> com.test.TestObj : null
groovy:000> foo.save
ERROR groovy.lang.MissingPropertyException: No such property: save for class: com.test.TestObj
를하고있는 중이 야 무엇 :
나는 한 가지를 시도?편집 : 좋아, 나는 .save
대신 .save()
을 사용하여 답변을 보았습니다. 하지만 이건 어때?
groovy:000> new com.test.TestObj().save()
ERROR org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
이번에는 무엇이 잘못 되었습니까?
예, withTransaction은 완벽하게 작동합니다. 왜 내가 그것을 추가해야하는지 궁금하다. 온라인 사례는 언급하지 않습니다. –
추가 할 필요는 없지만 문제가 해결 될 것이라고 생각했습니다. 트랜잭션 내에서 코드를 실행하면 최대 절전 모드 세션 생성이 강제로 이루어집니다 (그렇지 않은 경우). –