I am trying to add a method to a grails domain class, for example.
class Item { String name String getReversedName() { name.reverse() } }
When I try to download the application using the grails console, I get the following error:
Called: org.springframework.beans.factory.BeanCreationException: Error creating bean named "sessionFactory": init method call failed; The nested exception is org.hibernate.PropertyNotFoundException: Could not find an installer for the reverseedName property in the Item class ... 18 more
It seems that Hibernate interprets getReversedName () as the getter for the property, however in this case it is a derived field and therefore should not be saved. Obviously, in my actual code, the business logic that I expose is more complex, but it has nothing to do with this issue. I want to be able to call item.reversedName in my / gsps code.
How can I give a (getter) property access to a method in a Grails domain class without trying Grails to map it to Hibernate?
source share