-->
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.  [ 10 posts ] 
Author Message
 Post subject: ORA-01722: invalid number while initializing a collection
PostPosted: Fri Jun 03, 2005 11:37 am 
Beginner
Beginner

Joined: Tue May 31, 2005 1:16 pm
Posts: 35
Location: Bogota, Colombia
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

_________________
Julian Garcia


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 12:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
So what are the types for the GPNN_EMPRESA, GPNC_GRUPO, and GPNC_PERMISO columns on the two tables? Do they match in type?

What are the corresponding types in the GppNivel class?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 1:03 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 1:16 pm
Posts: 35
Location: Bogota, Colombia
The tables look like this:

Code:
create table GPN_GPP_NIVEL
(
  GPNC_GRUPO   VARCHAR(20) not null,
  GPNC_PERMISO VARCHAR(20) not null,
  GPNN_EMPRESA NUMERIC(2) not null,
  GPNC_NIVEL   CHAR(3) not null
)
;

create table GPP_GRUPO_PERMISO
(
  GPPC_GRUPO   VARCHAR(20) not null,
  GPPC_PERMISO VARCHAR(20) not null,
  GPPN_EMPRESA NUMERIC(2) not null,
  GPPN_ORDEN   NUMERIC(2) not null
)
;


Types in GppNivel
Code:
 
    private GppNivelPK comp_id;

    private GrupoPermiso grupoPermiso;

    NvaPermiso nvaPermiso;



In GppNivelPK class I have

Code:
    private String grupo;

    private String permiso;

    private Integer empresa;


Hope this help us to clarify the problem.

Thanks.

_________________
Julian Garcia


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 3:56 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 1:16 pm
Posts: 35
Location: Bogota, Colombia
I tried this using oracle's version 9, changing the dialect to Oracle9Dialect and got the same error. I have no idea what's wrong....

_________________
Julian Garcia


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 03, 2005 8:34 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
It is format type error - there are more possibilities
For example,
type in database NUMBER

you define in java String

Oracle do automatic conversion when you have correct data
For exampel, if you try set strings '2', '2.2' etc it is fine, but if you try set string 'A' to numeric
column you get 1722 - invalid number

There are another posibilities, for example : incorrect date etc

regards


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 1:18 am 
Beginner
Beginner

Joined: Tue May 31, 2005 1:16 pm
Posts: 35
Location: Bogota, Colombia
My Java and Oracle types are consistent. I have mapped numbers to Integers, and most of my keys are varchars, mapped to Strings. What would be the solution from this point of view?

_________________
Julian Garcia


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 05, 2005 8:49 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
it is format error - double check oracle and java types - you haven't coorect column order
in composite id (PK)

try simple query/dml with sqlplus - same query like with hibernate

regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 3:40 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 1:16 pm
Posts: 35
Location: Bogota, Colombia
It works now. We corrected the order. Anyways, I wonder why did it work fine with mySQL and not with oracle....

Thanks a lot.

_________________
Julian Garcia


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 5:13 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
I don't know mysql, but you can see contents of tables in mysql - I think that you have wrong contents (when PK have incorrect order)

regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 07, 2005 6:13 pm 
Beginner
Beginner

Joined: Tue May 31, 2005 1:16 pm
Posts: 35
Location: Bogota, Colombia
Thanks a lot problem solved!

_________________
Julian Garcia


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.