Ola
Depois de ler o pequeno tutorial “Introdução ao Hibernate 3” do GUJ e dar uma revisada na documentação online do próprio ( muito boa, por sinal )
Consegui instalar, configurar, e fazer rodar com tabelas sem relacionamento.
Estou batendo a cabeça pra fazer um relacionamento simples ( Parent/ Child, conforme a doc. online ), provavelmente por algum erro besta de iniciante, que não estou encontrando.
Minhas classes :
public class Parent {
private String nome ;
private String descricao;
private Integer id;
private Set children = new HashSet();
public Set getChildren() {
return this.children;
}
public void setChildren( Set children) {
this.children = children;
}
public String getNome() {
return this.nome ;
}
public void setNome( String nome ) {
this.nome = nome;
}
public Integer getId() {
return id;
}
private void setId(Integer id) {
this.id = id;
}
}
public class Child {
private String nome ;
private Integer id;
private Set parent ;
public String getNome() {
return this.nome ;
}
public void setNome( String nome ) {
this.nome = nome;
}
public Integer getId() {
return id;
}
private void setId(Integer id) {
this.id = id;
}
public Set getParent() {
return this.parent;
}
public void setParent( Set parent) {
this.parent=parent;
}
}
Meus xmls de mapeamento :
Parent.hbm.xml
<hibernate-mapping>
<class name="Parent">
<!-- Identificador da classe -->
<id name="id">
<generator class="increment"/>
</id>
<!-- Propriedades da classe -->
<property name="nome"/>
<set name="children">
<key column="parent_id" not-null="true"/>
<one-to-many class="Child"/>
</set>
</class>
</hibernate-mapping>
Child.hbm.xml
<hibernate-mapping>
<class name="Child">
<!-- Identificador da classe -->
<id name="id">
<generator class="increment"/>
</id>
<!-- Propriedades da classe -->
<property name="nome"/>
<many-to-one name="parent" column="parent_id" not-null="true"/>
</class>
</hibernate-mapping>
o erro :
An association from the table Child refers to an unmapped class:
java.util.Set
quando tiro a tag many-to-one de Child.hbm.xml, compila sem o erro.
Alguma dica ?
[ ]
Adriano