How can I find what relationship mapped by hibernate in a class of property?
Code:
public class Usuario {
private long id;
private List veiculoList; // ?? on-to-many ou many-to-many ??
private List enderecoList; // ?? on-to-many ou many-to-many ??
}
I need to know what kind of relationship is the property veiculoList and enderecoList, need to know whether they are one-to-many or many-to-many, where many-to-many, need to know what the name of the group table, also need to know ids of the foreign keys that are related within the group.
I'm trying use Hibernate API.
How does the Hibernate mapping, believe in your api must have a means of rebuilding the relationship of a property.
I need to create a code that looks like this:
Code:
for(Propriedade propriedade : listDePropriedades){
if(propriedade.isManyToMany()){
realizaProcesamento();
}
}
Hibernate version: 3.3.1
Mapping documents:Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.wealthsystems.sim.model.entity">
<class name="Usuario">
<id name="idUsuario" unsaved-value="undefined" type="long">
<generator class="native">
<param name="sequence">seqPkUsuario</param>
</generator>
</id>
<!-- Properties -->
<property name="idnAtivo" type="com.wealthsystems.sim.hbmdao.type.ByteType"
not-null="true" />
<!-- FKs -->
<many-to-one name="usuarioSuperior" column="idUsuarioSuperior"
class="Usuario" />
<bag name="enderecoList" inverse="true">
<key column="idEndereco" />
<one-to-many class="Endereco" />
</bag>
<bag name="veiculoList" table="UsuarioVeiculo" inverse="true">
<key column="idUsuario" />
<many-to-many column="idVeiculo" class="Veiculo" unique="false" />
</bag>
</class>
</hibernate-mapping>