These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: problems with a mapping!! Someone can help me please?!!
PostPosted: Thu Feb 07, 2008 1:32 pm 
Newbie

Joined: Wed Dec 05, 2007 8:26 am
Posts: 3
Location: Brazil
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...


Last edited by ThiagoWorldCoder on Thu Feb 07, 2008 2:22 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 07, 2008 1:53 pm 
Newbie

Joined: Mon Aug 15, 2005 3:43 am
Posts: 15
Use
<key-many-to-one name="tabela" class="TabelaBean" column="column_name"/>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.