I am having this problem while initializing a collection.
At first i thought it was a driver problem, but I continue to receive the same error after trying DataAccess and other comercial drivers.
I moved my data to mySQL and it worked fine. Problem is, i need to work on Oracle... I guess it is related to the dialect I am using (OracleDialect, also tried with generic and 9 dialects)...
Please Help...
Here the info:
Hibernate version: 2.1.6
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="co.com.atenaerp.seguridad.bo.GrupoPermiso"
table="GPP_GRUPO_PERMISO"
>
<composite-id name="comp_id" class="co.com.atenaerp.seguridad.bo.GrupoPermisoPK">
<key-property
name="grupo"
column="GPPC_GRUPO"
type="java.lang.String"
length="20"
/>
<key-property
name="permiso"
column="GPPC_PERMISO"
type="java.lang.String"
length="20"
/>
<key-property
name="empresa"
column="GPPN_EMPRESA"
type="java.lang.Integer"
length="2"
/>
</composite-id>
<property
name="orden"
type="int"
column="GPPN_ORDEN"
not-null="true"
length="2"
/>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- bi-directional many-to-one association to Grupo -->
<many-to-one
name="grupo"
class="co.com.atenaerp.seguridad.bo.Grupo"
update="false"
insert="false"
>
<column name="GPPC_GRUPO" />
</many-to-one>
<!-- bi-directional many-to-one association to Permiso -->
<many-to-one
name="permiso"
class="co.com.atenaerp.seguridad.bo.Permiso"
update="false"
insert="false"
>
<column name="GPPC_PERMISO" />
</many-to-one>
<!-- bi-directional many-to-one association to Empresa -->
<many-to-one
name="empresa"
class="co.com.atenaerp.seguridad.bo.Empresa"
update="false"
insert="false"
>
<column name="GPPN_EMPRESA" />
</many-to-one>
<!-- end of derived association(s) -->
<!-- bi-directional one-to-many association to GppNivel -->
<set
name="gppNivels"
lazy="true"
inverse="true"
cascade="none"
>
<key>
<column name="GPNN_EMPRESA" />
<column name="GPNC_GRUPO" />
<column name="GPNC_PERMISO" />
</key>
<one-to-many
class="co.com.atenaerp.seguridad.bo.GppNivel"
/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Grupo grupo = this.grupoDao.obtenerGrupo("ERP");
assertNotNull("el grupo es nulo!",grupo);
Set grupoPermiso = grupo.getGrupoPermisos();
Iterator itGrupoPermiso = grupoPermiso.iterator();
while (itGrupoPermiso.hasNext()) {
GrupoPermiso element = (GrupoPermiso) itGrupoPermiso.next();
Set gppNiveles = element.getGppNivels();
Iterator itGppNiveles = gppNiveles.iterator();
while (itGppNiveles.hasNext()) {
GppNivel gppNivel = (GppNivel) itGppNiveles.next();
}
}
}
Full stack trace of any exception that occurs:
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection
at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:201)
Caused by: net.sf.hibernate.JDBCException: could not initialize collection: [co.com.atenaerp.seguridad.bo.GrupoPermiso.gppNivels#co.com.atenaerp.seguridad.bo.GrupoPermisoPK@151b0a5[grupo=ADM,permiso=segUsuario,empresa=1]]
Caused by: java.sql.SQLException: ORA-01722: invalid number
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:420)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:896)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:452)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:986)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2888)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2929)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
Name and version of the database you are using:
Oracle 8.1.7
The generated SQL (show_sql=true):
Hibernate: select grupo0_.GRPC_CODIGO as GRPC_COD1_0_, grupo0_.GRPC_DESCRIPCION as GRPC_DES2_0_ from GRP_GRUPO grupo0_ where grupo0_.GRPC_CODIGO=?
Hibernate: select grupopermi0_.GPPC_GRUPO as GPPC_GRUPO__, grupopermi0_.GPPC_PERMISO as GPPC_PER2___, grupopermi0_.GPPN_EMPRESA as GPPN_EMP3___, grupopermi0_.GPPC_GRUPO as GPPC_GRUPO4_, grupopermi0_.GPPC_PERMISO as GPPC_PER2_4_, grupopermi0_.GPPN_EMPRESA as GPPN_EMP3_4_, grupopermi0_.GPPN_ORDEN as GPPN_ORDEN4_, grupopermi0_.GPPC_GRUPO as GPPC_GRUPO4_, grupopermi0_.GPPC_PERMISO as GPPC_PER2_4_, grupopermi0_.GPPN_EMPRESA as GPPN_EMP3_4_, permiso1_.PERC_CODIGO as PERC_COD1_0_, permiso1_.PERC_DESCRIPCION as PERC_DES2_0_, permiso1_.PERC_KEY as PERC_KEY0_, permiso1_.PERC_URL as PERC_URL0_, permiso1_.PERC_GIF as PERC_GIF0_, permiso1_.PERC_SHORTCUT as PERC_SHO6_0_, permiso1_.PERC_TIPO as PERC_TIPO0_, permiso1_.PERC_MODULO as PERC_MOD8_0_, permiso1_.PERC_PADRE as PERC_PADRE0_, modulo2_.MODC_CODIGO as MODC_COD1_1_, modulo2_.MODC_NOMBRE as MODC_NOM2_1_, modulo2_.MODC_GIF as MODC_GIF1_, modulo2_.MODC_URL as MODC_URL1_, modulo2_.MODC_KEY as MODC_KEY1_, modulo2_.MODN_ORDEN as MODN_ORDEN1_, modulo2_.MODC_APLICACION as MODC_APL7_1_, aplicacion3_.APLC_CODIGO as APLC_COD1_2_, aplicacion3_.APLC_DESCRIPCION as APLC_DES2_2_, aplicacion3_.APLC_KEY as APLC_KEY2_, aplicacion3_.APLC_ESTADO as APLC_EST4_2_, empresa4_.EMPN_CODIGO as EMPN_COD1_3_, empresa4_.EMPC_NOMBRE as EMPC_NOM2_3_, empresa4_.EMPC_RAZON_SOCIAL as EMPC_RAZ3_3_, empresa4_.EMPN_NIT as EMPN_NIT3_, empresa4_.EMPN_DIGITO_VERIFICACION as EMPN_DIG5_3_, empresa4_.EMPC_DIRECCION as EMPC_DIR6_3_, empresa4_.EMPC_TELEFONO as EMPC_TEL7_3_, empresa4_.EMPC_ESTADO as EMPC_EST8_3_ from GPP_GRUPO_PERMISO grupopermi0_, PER_PERMISO permiso1_, MOD_MODULO modulo2_, APL_APLICACION aplicacion3_, EMP_EMPRESA empresa4_ where grupopermi0_.GPPC_GRUPO=? and grupopermi0_.GPPC_PERMISO=permiso1_.PERC_CODIGO(+) and permiso1_.PERC_MODULO=modulo2_.MODC_CODIGO(+) and modulo2_.MODC_APLICACION=aplicacion3_.APLC_CODIGO(+) and grupopermi0_.GPPN_EMPRESA=empresa4_.EMPN_CODIGO(+)
Hibernate: select gppnivels0_.GPNN_EMPRESA as GPNN_EMP3___, gppnivels0_.GPNC_GRUPO as GPNC_GRUPO__, gppnivels0_.GPNC_PERMISO as GPNC_PER2___, gppnivels0_.GPNC_NIVEL as GPNC_NIVEL__, gppnivels0_.GPNC_GRUPO as GPNC_GRUPO5_, gppnivels0_.GPNC_PERMISO as GPNC_PER2_5_, gppnivels0_.GPNN_EMPRESA as GPNN_EMP3_5_, gppnivels0_.GPNC_NIVEL as GPNC_NIVEL5_, gppnivels0_.GPNN_EMPRESA as GPNN_EMP3_5_, gppnivels0_.GPNC_GRUPO as GPNC_GRUPO5_, gppnivels0_.GPNC_PERMISO as GPNC_PER2_5_, gppnivels0_.GPNC_NIVEL as GPNC_NIVEL5_, nvapermiso1_.NAPC_NIVEL as NAPC_NIVEL0_, nvapermiso1_.NAPC_PERMISO as NAPC_PER2_0_, nvapermiso1_.NAPC_URL as NAPC_URL0_, nvapermiso1_.NAPC_PERMISO as NAPC_PER2_0_, nvapermiso1_.NAPC_NIVEL as NAPC_NIVEL0_, permiso2_.PERC_CODIGO as PERC_COD1_1_, permiso2_.PERC_DESCRIPCION as PERC_DES2_1_, permiso2_.PERC_KEY as PERC_KEY1_, permiso2_.PERC_URL as PERC_URL1_, permiso2_.PERC_GIF as PERC_GIF1_, permiso2_.PERC_SHORTCUT as PERC_SHO6_1_, permiso2_.PERC_TIPO as PERC_TIPO1_, permiso2_.PERC_MODULO as PERC_MOD8_1_, permiso2_.PERC_PADRE as PERC_PADRE1_, modulo3_.MODC_CODIGO as MODC_COD1_2_, modulo3_.MODC_NOMBRE as MODC_NOM2_2_, modulo3_.MODC_GIF as MODC_GIF2_, modulo3_.MODC_URL as MODC_URL2_, modulo3_.MODC_KEY as MODC_KEY2_, modulo3_.MODN_ORDEN as MODN_ORDEN2_, modulo3_.MODC_APLICACION as MODC_APL7_2_, aplicacion4_.APLC_CODIGO as APLC_COD1_3_, aplicacion4_.APLC_DESCRIPCION as APLC_DES2_3_, aplicacion4_.APLC_KEY as APLC_KEY3_, aplicacion4_.APLC_ESTADO as APLC_EST4_3_, nivelacces5_.NVAC_CODIGO as NVAC_COD1_4_, nivelacces5_.NVAC_NOMBRE as NVAC_NOM2_4_ from GPN_GPP_NIVEL gppnivels0_, NAP_NVA_PERMISO nvapermiso1_, PER_PERMISO permiso2_, MOD_MODULO modulo3_, APL_APLICACION aplicacion4_, NVA_NIVEL_ACCESO nivelacces5_ where gppnivels0_.GPNN_EMPRESA=? and gppnivels0_.GPNC_GRUPO=? and gppnivels0_.GPNC_PERMISO=? and gppnivels0_.GPNC_NIVEL=nvapermiso1_.NAPC_NIVEL(+) and gppnivels0_.GPNC_PERMISO=nvapermiso1_.NAPC_PERMISO(+) and nvapermiso1_.NAPC_PERMISO=permiso2_.PERC_CODIGO(+) and permiso2_.PERC_MODULO=modulo3_.MODC_CODIGO(+) and modulo3_.MODC_APLICACION=aplicacion4_.APLC_CODIGO(+) and nvapermiso1_.NAPC_NIVEL=nivelacces5_.NVAC_CODIGO(+)
Debug level Hibernate log excerpt:
WARNING: SQL Error: 1722, SQLState: 42000
03-jun-2005 10:33:49 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
GRAVE: ORA-01722: invalid number