I am getting the following exception when initializing my service...
[INFO] [grails.bat] Error executing script TestApp: 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: Repeated column in mapping for entity: BookmarkGadget column: gadgets_id (should be mapped with insert="false" update="false")Here is what my class looks like...
Code:
class BookmarkGadget extends BaseGadget{
Integer gadgetsId
Blob urlData
String url
static mapping = {
table 'gadget_bookmark'
id column:'id', sqlType:int //added for mysql
version sqlType:int
gadgetsId column:'gadgets_id', sqlType:int
urlData type:'blob'
gadgets cascade:'all'
}
I am not sure what this exception is trying to tell me? I searched my code and this is the only place that the gadgetsId mapping is defined.
If I take out the "Integer gadgetsId" then the exception goes away, but then I get an exception that the gadgets_id column is a int when hibernate is expecting a bigint.
I added the "gadgetsId column:'gadgets_id', sqlType:int" and "Integer gadgetsId" to tell hibernate that my MySQL database has the column defined as int instead of a bigint.
This fix has worked for other INT(11) columns on different tables, but doesn't seem to work for the gadgets_id column. Any ideas why?
All I need to do is tell hibernate that the column is a int not a bigint.