Trying to use a grails domain class from the shell

Posted by ????? on Stack Overflow See other posts from Stack Overflow or by ?????
Published on 2010-03-02T05:19:33Z Indexed on 2010/05/11 21:24 UTC
Read the original article Hit count: 269

Filed under:
|
|
|
|

I'm new to Grails.

I'm trying to experiement with my grails domains from the shell, and I can't get it to work. These domains work fine from the scaffold code when I run the app.

Given this domain class

class IncomingCall {

    String caller_id
    Date call_time
    int  call_length

    static constraints = {
    }
}

I try to create an "IncomingCall" and save it from the shell. No matter what I do, I always get "Null"; the object isn't created.

And if I try to create the object and then do a save, I get the "No hibernate session bound to thread" error (see below).

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> 

How can I make this work from the shell?

© Stack Overflow or respective owner

Related posts about groovy

Related posts about grails