I'm studying "Chapter 6. Components", and I did the the following example:
Code:
<class name="vo.PersonVO" table="person">
<id name="id" column="id" type="int">
<generator class="sequence"/>
</id>
<property name="birthday" type="date"/>
<component name="name" class="vo.NamePerson">
<parent name="person"/> <!-- reference back to the Person -->
<property name="initial" type="char"/>
<property name="first" type="string"/>
<property name="last" type="string"/>
</component>
</class>
In this component, I put a <parent> subelement...
Quote:
The <component> element allows a <parent> subelement that maps a property of the component class as a reference back to the containing entity.
When I run the hbm2java.CodeGenerator to generate the class, two classes are generated, the PersonVO and the NamePerson.
Shouldn't the NamePerson class have a property "person" that references the PersonVO ? If not, How can I accomplish that?
Code:
/** @author Hibernate CodeGenerator */
public class NamePerson implements Serializable {
/** nullable persistent field */
private char initial;
/** nullable persistent field */
private String first;
/** nullable persistent field */
private String last;
then, when I run the SchemaExport, the following error happens:
net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property person in class vo.NamePerson...
I think that the NamePerson class needs a property "PersonVO person;", then when I put the "private PersonVO person;" attribute in the NamePerson class, the SchemaExport runs successfully!
am I right?
thanks