Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.3
POJO:
Code:
public class SiteDBBean implements Serializable {
private int codigoMatrizGrupo;
private int codigoEmpresa;
private TabelaBean tabela;
private int codigoSite;
private String senha;
private int dataAlteracao;
private String horaAlteracao;
private int dataUltimaSinc;
private String horaUltimaSinc;
private int dataInicioSinc;
private String horaInicioSinc;
.
.
.
getters and setters
hashcode and equals...
}
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="br.com.consist.databridge.bean">
<typedef name="" class="br.com.consist.bean.TabelaBean"></typedef>
<class name="SiteDBBean" table="PDV_SITE_SINC">
<composite-id>
<key-property name="codigoEmpresa" type="integer" column="PDV01_EMPRESA" />
<key-property name="codigoMatrizGrupo" type="integer" column="PDV01_MAT_GRU" />
<key-property name="codigoSite" type="integer" column="PDV01_ID_SITE" />
<key-property name="tabela" type="??????" column="PDV01_TABELA" />
</composite-id>
<property name="senha" type="string" column="PDV01_SENHA" />
<property name="dataUltimaSinc" type="integer" column="PDV01_DTULSIN" />
<property name="horaUltimaSinc" type="string" column="PDV01_HRULSIN" />
<property name="dataAlteracao" type="integer" column="PDV01_DTALTER" />
<property name="horaAlteracao" type="string" column="PDV01_HOALTER" />
<property name="dataInicioSinc" type="integer" column="PDV01_DTINIC" />
<property name="horaInicioSinc" type="string" column="PDV01_HRINIC" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
SiteDBBean site = new SiteDBBean();
Session sessao = HibernateUtil.getSessionFactory().openSession();
Transaction tx = sessao.beginTransaction();
List lista = sessao.createQuery("from SiteDBBean").list();
tx.commit();
System.out.println("tamanho da lista: "+lista.size());
sessao.close();
Name and version of the database you are using:Adabas D 13.01.00
The generated SQL (show_sql=true):
Hi, good afternoon!
I am trying to make the mapping from this pojo, I know how to use the tag component, but, how can I map that if a piece of my composite-id is a component?
How can I do this mapping? Please help me!!
thanks a lot!!
ps.
But that classe TabelaBean isn't from another tabela...