Quote:
Does the persistent class need a property, getters and setters when modifying its Class Mapping ?
No, the class doesn't need that, but if there is no getter/setter or property in a class you need to provide another mechanism that takes care of the values. If you check the Hibernate documentation (
http://www.hibernate.org/hib_docs/v3/re ... n-property) you will find that for a
<property> definition you can specify the attribute
access="field|property|ClassName". The default values is
access="property" which means that Hibernate expects a getter/setter pair. The
access="field" option means that Hibernate uses a class variable. The
access="ClassName" option specifies a class that must implement the org.hibernate.property.PropertyAccessor interface.
So, from your description it seems like you want the last case. Eg. you need to create a PropertyAccessor implementation. Then, you specify the name of that class in a call to Property.setPropertyAccessorName(). Eg.
Code:
Property prop = new Property();
prop.setName("motto");
prop.setValue(value);
prop.setPropertyAccessorName("the.name.of.a.PropertyAccessor");
Quote:
If I add the property motto and its methods as per the exception in persistent class, I get an error
You also need to call Property.setNodeName(). Use the same value as for Property.setName().
We are doing something similar in our project. Below are some links to our code.
http://base.thep.lu.se/browser/tags/2.9 ... .java#L357
http://base.thep.lu.se/browser/tags/2.9 ... essor.java