【发布时间】:2010-03-02 05:19:33
【问题描述】:
我是 Grails 的新手。
我正在尝试从 shell 中使用我的 grails 域,但我无法让它工作。当我运行应用程序时,这些域在脚手架代码中运行良好。
给定这个域类
class IncomingCall {
String caller_id
Date call_time
int call_length
static constraints = {
}
}
我尝试创建一个“IncomingCall”并从 shell 中保存它。无论我做什么,我总是得到“空”;该对象未创建。
如果我尝试创建对象然后保存,我会收到“No hibernate session bound to thread”错误(见下文)。
groovy:000> new IncomingCall(caller_id:'555-1212', call_time: new Date(), call_length:10).save()
ERROR org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession (SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession (SessionFactoryImpl.java:574)
at groovysh_evaluate.run (groovysh_evaluate:3)
...
groovy:000>
如何在 shell 中完成这项工作?
【问题讨论】:
标签: hibernate spring shell grails groovy