4
votes

I'm using Grails 1.2.1. I'm converting a Java app to a Grails app and I had a Java object that I thought I'd create a grails domain for. However, the object does not rely on an underlying database table. When I startup my app, I'm getting the error,

ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: java.io.InputStream, at table: http_cache_response, for columns: [org.hibernate.mapping.Column(body)]

Am I misusing the domain? Should this object just be a regular class in src/groovy? Thanks, - Dave

4
How do I do that? The only obvious button at the bottom is "Answer Your Question" but seems to be a way to reply to the thread. There is a lot going on in these pages -- screencast.com/t/JzOa4hrX ! - DaveDave
I haven't yet asked a question myself, so I had to search in the FAQ to find out how. "When you have decided which answer is the most helpful to you, mark it as the accepted answer by clicking on the check box outline to the left of the answer."Dana

4 Answers

9
votes

Yes, domain objects are specifically database-mapped objects. Not domain in the DDD sense.

Depending on if the class is a singleton or not it should either be a service or a class in src/groovy.

5
votes

It's possible to create a class that does not have an underlying domain object. There are 2 cases:

  1. You want an object to use in Controller, you may create a Command Object.

  2. If you want to create a pure java or groovy class, you can create it in src/java or src/groovy.

0
votes

I would say if your not going to use the class as a grails style domain object, it's better to put it in src/java and use them like any other class.

0
votes

You might want to check out mapWith property of domain classes:

static mapWith = "none" should do the trick