I've migrated from a MySQL DB to a BD2 DB and some sets are not initialized for the DB2 DB.
The hibernate configuration file is (including properties for connecting each DB):
"-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- Comun --> <property name="hibernate.show_sql">true</property> <property name="hibernate.bytecode.use_reflection_optimizer">false</property> <property name="hibernate.current_session_context_class">thread</property>
<!-- DB2 -->
<property name="hibernate.connection.driver_class">com.ibm.db2.jcc.DB2Driver</property> <property name="hibernate.connection.url">jdbc:db2://localhost:60055/UDCDBKS0</property> <property name="hibernate.connection.username">consulta</property> <property name="hibernate.connection.password">xxxxxxxxx</property> <property name="hibernate.default_schema">DESADM</property> <property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property> <!-- MYSQL --> <!-- <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/db2</property> <property name="hibernate.connection.username">consulta</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> --> <mapping resource="CtrlopUsuario.hbm.xml" /> <mapping resource="CtrlopPerfAcc.hbm.xml" /> <mapping resource="CtrlopPerfDat.hbm.xml" /> <mapping resource="CtrlopRegion.hbm.xml" /> <mapping resource="CtrlopEmpresa.hbm.xml" /> </session-factory> </hibernate-configuration>
The xml config file of the table where the initialization of the sets has problems is:
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated 15-jul-2009 12:58:22 by Hibernate Tools 3.2.2.GA --> <hibernate-mapping> <class name="CtrlopUsuario" table="ctrlop_usuario" > <id name="g4108UsuLdap" type="string"> <column name="G4108_USU_LDAP" length="30" /> <generator class="assigned" /> </id> <many-to-one name="ctrlopPerfAcc" class="CtrlopPerfAcc" fetch="select"> <column name="G4108_COD_PERF" length="2" /> </many-to-one> <many-to-one name="ctrlopPerfDat" class="CtrlopPerfDat" fetch="select"> <column name="G4108_IDPERFIL" length="2" /> </many-to-one> <set name="ctrlopEmpresas" inverse="false" table="ctrlop_usregemp"> <key> <column name="G4112_USU_LDAP" length="30" not-null="true" /> </key> <many-to-many entity-name="CtrlopEmpresa"> <column name="G4112_IDEMPR" length="4" not-null="true" /> <column name="G4112_CDCANAL" length="3" not-null="true" /> </many-to-many> </set> <set name="ctrlopRegions" inverse="false" table="ctrlop_usuregi"> <key> <column name="G4109_USU_LDAP" length="30" not-null="true" /> </key> <many-to-many entity-name="CtrlopRegion"> <column name="G4109_IDREGI" length="2" not-null="true" /> </many-to-many> </set> </class> </hibernate-mapping>
And the associate POJO:
// default package // Generated 15-jul-2009 12:58:22 by Hibernate Tools 3.2.2.GA
import java.util.HashSet; import java.util.Set;
/** * CtrlopUsuario generated by hbm2java */ public class CtrlopUsuario implements java.io.Serializable {
private String g4108UsuLdap; private CtrlopPerfAcc ctrlopPerfAcc; private CtrlopPerfDat ctrlopPerfDat; private Set ctrlopEmpresas = new HashSet(0); private Set ctrlopRegions = new HashSet(0);
public CtrlopUsuario() { }
public CtrlopUsuario(String g4108UsuLdap) { this.g4108UsuLdap = g4108UsuLdap; }
public CtrlopUsuario(String g4108UsuLdap, CtrlopPerfAcc ctrlopPerfAcc, CtrlopPerfDat ctrlopPerfDat, Set ctrlopEmpresas, Set ctrlopRegions) { this.g4108UsuLdap = g4108UsuLdap; this.ctrlopPerfAcc = ctrlopPerfAcc; this.ctrlopPerfDat = ctrlopPerfDat; this.ctrlopEmpresas = ctrlopEmpresas; this.ctrlopRegions = ctrlopRegions; }
public String getG4108UsuLdap() { return this.g4108UsuLdap; }
public void setG4108UsuLdap(String g4108UsuLdap) { this.g4108UsuLdap = g4108UsuLdap; }
public CtrlopPerfAcc getCtrlopPerfAcc() { return this.ctrlopPerfAcc; }
public void setCtrlopPerfAcc(CtrlopPerfAcc ctrlopPerfAcc) { this.ctrlopPerfAcc = ctrlopPerfAcc; }
public CtrlopPerfDat getCtrlopPerfDat() { return this.ctrlopPerfDat; }
public void setCtrlopPerfDat(CtrlopPerfDat ctrlopPerfDat) { this.ctrlopPerfDat = ctrlopPerfDat; }
public Set getCtrlopEmpresas() { return this.ctrlopEmpresas; }
public void setCtrlopEmpresas(Set ctrlopEmpresas) { System.out.println("USUARIO setCtrlopEmpresas: "+ctrlopEmpresas.size()); this.ctrlopEmpresas = ctrlopEmpresas; }
public Set getCtrlopRegions() { return this.ctrlopRegions; }
public void setCtrlopRegions(Set ctrlopRegions) { System.out.println("USUARIO setCtrlopRegions: "+ctrlopRegions.size()); this.ctrlopRegions = ctrlopRegions; }
}
When i run the client the following quereis/bindings/results are generated:
- For the DB2 DB:
[2009-07-15 14:34:44,968] DEBUG [main] (SQLStatementLogger.java:111) - select ctrlopusua0_.G4108_USU_LDAP as G1_0_0_, ctrlopusua0_.G4108_COD_PERF as G2_0_0_, ctrlopusua0_.G4108_IDPERFIL as G3_0_0_ from DESADM.ctrlop_usuario ctrlopusua0_ where ctrlopusua0_.G4108_USU_LDAP=? [2009-07-15 14:34:45,000] TRACE [main] (NullableType.java:151) - binding 'Usuario1' to parameter: 1 [2009-07-15 14:34:45,031] TRACE [main] (NullableType.java:193) - returning '01' as column: G2_0_0_ [2009-07-15 14:34:45,046] TRACE [main] (NullableType.java:193) - returning '01' as column: G3_0_0_ [2009-07-15 14:34:45,062] DEBUG [main] (SQLStatementLogger.java:111) - select ctrlopempr0_.G4112_USU_LDAP as G1_1_, ctrlopempr0_.G4112_IDEMPR as G2_1_, ctrlopempr0_.G4112_CDCANAL as G3_1_, ctrlopempr1_.G4110_IDEMPR as G1_7_0_, ctrlopempr1_.G4110_CDCANAL as G2_7_0_, ctrlopempr1_.G4110_NOMENT as G3_7_0_ from DESADM.ctrlop_usregemp ctrlopempr0_ left outer join DESADM.ctrlop_empresa ctrlopempr1_ on ctrlopempr0_.G4112_IDEMPR=ctrlopempr1_.G4110_IDEMPR and ctrlopempr0_.G4112_CDCANAL=ctrlopempr1_.G4110_CDCANAL where ctrlopempr0_.G4112_USU_LDAP=? [2009-07-15 14:34:45,062] TRACE [main] (NullableType.java:151) - binding 'Usuario1' to parameter: 1 [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning '0049' as column: G1_7_0_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning 'OFI' as column: G2_7_0_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning 'Banco Santander ' as column: G3_7_0_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning 'Usuario1 ' as column: G1_1_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning '0049' as column: G2_1_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning 'OFI' as column: G3_1_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning '0030' as column: G1_7_0_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning 'OFI' as column: G2_7_0_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning 'Banesto ' as column: G3_7_0_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning 'Usuario1 ' as column: G1_1_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning '0030' as column: G2_1_ [2009-07-15 14:34:45,078] TRACE [main] (NullableType.java:193) - returning 'OFI' as column: G3_1_ [2009-07-15 14:34:45,093] DEBUG [main] (SQLStatementLogger.java:111) - select ctrlopregi0_.G4109_USU_LDAP as G1_1_, ctrlopregi0_.G4109_IDREGI as G2_1_, ctrlopregi1_.G4106_IDREGI as G1_5_0_, ctrlopregi1_.G4106_DESCRIRG as G2_5_0_ from DESADM.ctrlop_usuregi ctrlopregi0_ left outer join DESADM.ctrlop_region ctrlopregi1_ on ctrlopregi0_.G4109_IDREGI=ctrlopregi1_.G4106_IDREGI where ctrlopregi0_.G4109_USU_LDAP=? [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:151) - binding 'Usuario1' to parameter: 1 [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:193) - returning '00' as column: G1_5_0_ [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:193) - returning 'Grupo ' as column: G2_5_0_ [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:193) - returning 'Usuario1 ' as column: G1_1_ [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:193) - returning '00' as column: G2_1_ [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:193) - returning '01' as column: G1_5_0_ [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:193) - returning 'España ' as column: G2_5_0_ [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:193) - returning 'Usuario1 ' as column: G1_1_ [2009-07-15 14:34:45,093] TRACE [main] (NullableType.java:193) - returning '01' as column: G2_1_
- For the MySql DB:
[2009-07-15 14:36:32,343] DEBUG [main] (SQLStatementLogger.java:111) - select ctrlopusua0_.G4108_USU_LDAP as G1_0_0_, ctrlopusua0_.G4108_COD_PERF as G2_0_0_, ctrlopusua0_.G4108_IDPERFIL as G3_0_0_ from ctrlop_usuario ctrlopusua0_ where ctrlopusua0_.G4108_USU_LDAP=? [2009-07-15 14:36:32,359] TRACE [main] (NullableType.java:151) - binding 'Usuario1' to parameter: 1 [2009-07-15 14:36:32,375] TRACE [main] (NullableType.java:193) - returning '01' as column: G2_0_0_ [2009-07-15 14:36:32,375] TRACE [main] (NullableType.java:193) - returning '01' as column: G3_0_0_ [2009-07-15 14:36:32,390] DEBUG [main] (SQLStatementLogger.java:111) - select ctrlopempr0_.G4112_USU_LDAP as G1_1_, ctrlopempr0_.G4112_IDEMPR as G2_1_, ctrlopempr0_.G4112_CDCANAL as G3_1_, ctrlopempr1_.G4110_IDEMPR as G1_7_0_, ctrlopempr1_.G4110_CDCANAL as G2_7_0_, ctrlopempr1_.G4110_NOMENT as G3_7_0_ from ctrlop_usregemp ctrlopempr0_ left outer join ctrlop_empresa ctrlopempr1_ on ctrlopempr0_.G4112_IDEMPR=ctrlopempr1_.G4110_IDEMPR and ctrlopempr0_.G4112_CDCANAL=ctrlopempr1_.G4110_CDCANAL where ctrlopempr0_.G4112_USU_LDAP=? [2009-07-15 14:36:32,390] TRACE [main] (NullableType.java:151) - binding 'Usuario1' to parameter: 1 [2009-07-15 14:36:32,390] TRACE [main] (NullableType.java:193) - returning '0030' as column: G1_7_0_ [2009-07-15 14:36:32,390] TRACE [main] (NullableType.java:193) - returning 'CAN' as column: G2_7_0_ [2009-07-15 14:36:32,390] TRACE [main] (NullableType.java:193) - returning 'Banesto' as column: G3_7_0_ [2009-07-15 14:36:32,390] TRACE [main] (NullableType.java:193) - returning 'Usuario1' as column: G1_1_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning '0030' as column: G2_1_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning 'CAN' as column: G3_1_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning '0049' as column: G1_7_0_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning 'CAN' as column: G2_7_0_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning 'Santander' as column: G3_7_0_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning 'Usuario1' as column: G1_1_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning '0049' as column: G2_1_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning 'CAN' as column: G3_1_ [2009-07-15 14:36:32,406] DEBUG [main] (SQLStatementLogger.java:111) - select ctrlopregi0_.G4109_USU_LDAP as G1_1_, ctrlopregi0_.G4109_IDREGI as G2_1_, ctrlopregi1_.G4106_IDREGI as G1_5_0_, ctrlopregi1_.G4106_DESCRIRG as G2_5_0_ from ctrlop_usuregi ctrlopregi0_ left outer join ctrlop_region ctrlopregi1_ on ctrlopregi0_.G4109_IDREGI=ctrlopregi1_.G4106_IDREGI where ctrlopregi0_.G4109_USU_LDAP=? [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:151) - binding 'Usuario1' to parameter: 1 [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning '00' as column: G1_5_0_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning 'Grupo' as column: G2_5_0_ [2009-07-15 14:36:32,406] TRACE [main] (NullableType.java:193) - returning 'Usuario1' as column: G1_1_ [2009-07-15 14:36:32,421] TRACE [main] (NullableType.java:193) - returning '00' as column: G2_1_ [2009-07-15 14:36:32,421] TRACE [main] (NullableType.java:193) - returning '01' as column: G1_5_0_ [2009-07-15 14:36:32,421] TRACE [main] (NullableType.java:193) - returning 'España' as column: G2_5_0_ [2009-07-15 14:36:32,421] TRACE [main] (NullableType.java:193) - returning 'Usuario1' as column: G1_1_ [2009-07-15 14:36:32,421] TRACE [main] (NullableType.java:193) - returning '01' as column: G2_1_
The results for the MySql BD are correctly mapped to the ctrlopEmpresas and ctrlopRegions sets. The results for the BD2 DB are not mapped to those sets...but objects contained in those sets are created correctly (CtrlopEmpresa and CtrlopRegion)
|