-->
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.  [ 8 posts ] 
Author Message
 Post subject: Stream has already been closed
PostPosted: Sun Aug 08, 2004 1:50 am 
Newbie

Joined: Mon Aug 02, 2004 12:11 pm
Posts: 10
Location: Mexico D.F.
hi, i have a trouble with a mapping, i read some messages where the people say that the problem is the data type long in oracle and the solution is that they read first the field long to retrieve data , but theirs querys are like :
rs1=st1.executeQuery("select * from contents where poemid=2");
while(rs1.next())
{
mean=rs1.getString(4);
poemid=rs1.getInt(1);
poem=rs1.getString(3);

But i run a test to obtain some fields but in a runtime i received this errors :

Aug 8, 2004 12:02:48 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17027, SQLState: null
Aug 8, 2004 12:02:48 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Stream has already been closed
Aug 8, 2004 12:02:48 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17027, SQLState: null
Aug 8, 2004 12:02:48 AM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Stream has already been closed
Aug 8, 2004 12:02:48 AM net.sf.hibernate.JDBCException <init>
SEVERE: SQLException occurred
java.sql.SQLException: Stream has already been closed
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.ttc7.LongTTCItem.getChars(LongTTCItem.java:189)
at oracle.jdbc.dbaccess.DBDataSetImpl.getCharsStreamItem(DBDataSetImpl.java:1630)
at oracle.jdbc.driver.OracleStatement.getCharsInternal(OracleStatement.java:3347)
at oracle.jdbc.driver.OracleStatement.getStringValue(OracleStatement.java:3556)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:434)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1482)
at net.sf.hibernate.type.StringType.get(StringType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:611)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:552)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:511)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:426)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:209)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:121)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3604)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
at ixemkt.sd.catalogos.dao.TmkCampaniaDAO.obtenDisCampania(TmkCampaniaDAO.java:55)
at ixemkt.util.test.Test.testobtenDisCampania(Test.java:60)
at ixemkt.util.test.Test.main(Test.java:48)

The HBM where i have the long field is this , i commented some things :

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="ixemkt.sd.catalogos">
<class
name="TmkCampania"
table="TMK_CAMPANIA"
>
<id
name="flCampania"
type="integer"
column="FL_CAMPANIA"
>
<generator class="vm"/>
</id>

<property
name="clUsrModifico"
column="CL_USR_MODIFICO"
type="integer"
not-null="false"
length="22"
/>
<property
name="remitente"
column="REMITENTE"
type="string"
not-null="false"
length="80"
/>
<property
name="clEstatus"
column="CL_ESTATUS"
type="integer"
not-null="false"
length="1"
/>
<property
name="feVigInicial"
column="FE_VIG_INICIAL"
type="date"
not-null="false"
length="7"
/>
<property
name="diasEsperaContactar"
column="DIAS_ESPERA_CONTACTAR"
type="integer"
not-null="false"
length="3"
/>
<!-- please tell Joe Hudson that the type 'LONG' could not be resolved.. defaulting to java.lang.String -->
<property
name="txtMail"
column="TXT_MAIL"
type="java.lang.String"
not-null="false"
/>
<property
name="dsCampania"
column="DS_CAMPANIA"
type="string"
not-null="false"
length="80"
/>
<property
name="fgEnvioMail"
column="FG_ENVIO_MAIL"
type="string"
not-null="false"
length="1"
/>
<property
name="feUltmod"
column="FE_ULTMOD"
type="date"
not-null="false"
length="7"
/>
<property
name="fgContactar"
column="FG_CONTACTAR"
type="string"
not-null="false"
length="1"
/>
<property
name="dsComentario"
column="DS_COMENTARIO"
type="string"
not-null="false"
length="1024"
/>
<property
name="clTpcampania"
column="CL_TPCAMPANIA"
type="integer"
not-null="false"
length="2"
/>
<property
name="asunto"
column="ASUNTO"
type="string"
not-null="false"
length="80"
/>
<property
name="feVigFinal"
column="FE_VIG_FINAL"
type="date"
not-null="false"
length="7"
/>
<property
name="diasVigAgenda"
column="DIAS_VIG_AGENDA"
type="integer"
not-null="false"
length="3"
/>
<property
name="flAseguimiento"
column="FL_ASEGUIMIENTO"
type="integer"
not-null="false"
/>
<property
name="clUnegocio"
column="CL_UNEGOCIO"
type="integer"
not-null="true"
length="4"
/>
<property
name="flAdifusion"
column="FL_ADIFUSION"
type="integer"
not-null="false"
/>
<property
name="flGuion"
column="FL_GUION"
type="integer"
not-null="false"
/>
<property
name="flGrupo"
column="FL_GRUPO"
type="integer"
not-null="false"
length="4"
/>
<property
name="flTipoTarea"
column="FL_TIPO_TAREA"
type="integer"
not-null="false"
/>
<many-to-one
name="empGuion"
class="TmkGuion"
insert="false"
update="false"
>
<column name="FL_GUION"/>
</many-to-one>




<!--
<many-to-one
name="empAnegocio"
class="TmkAreaNegocio"
insert="false"
update="false"
>
<column name="CL_UNEGOCIO"/>
<column name="FL_ADIFUSION"/>
</many-to-one>


<set inverse="true" lazy="true" name="archivoSet">
<key column="FL_CAMPANIA" />
<one-to-many class="TmkCampaniaArchivo" />
</set>

<set inverse="true" lazy="true" name="tmkUsuarioSet">
<key column="FL_CAMPANIA" />
<one-to-many class="TmkUsuario" />
</set>

<set inverse="true" lazy="true" name="datoAdicSet">
<key column="FL_CAMPANIA" />
<one-to-many class="TmkCampaniaDatoAdic" />
</set>

<set inverse="true" lazy="true" name="tmkBaseDatosSet">
<key column="FL_CAMPANIA" />
<one-to-many class="TmkBaseDatos" />
</set>

<many-to-one
name="empActividad"
class="TmkActividad"
insert="false"
update="false"
>
<column name="FL_TIPO_TAREA"/>
</many-to-one>





<many-to-one
name="empGrupo"
class="TmkGrupo"
insert="false"
update="false"
>
<column name="FL_GRUPO"/>
<column name="FL_ASEGUIMIENTO"/>
<column name="CL_UNEGOCIO"/>
</many-to-one>

-->


</class>
</hibernate-mapping>

My DAO CLASS :

public List obtenDisCampania(String[] parametros) throws HibernateException{
ResourceBundle bundle;

bundle=ResourceBundle.getBundle("resources.GlobalExceptions");
if(parametros.length!=3){
throw new IllegalArgumentException(bundle.getString("cat.obtenDisCampania.errParams"));
}
//TmkCampania camp= new TmkCampania();
//camp.s
//Se generan los criterios de busqueda
Criteria criterios = getSession().createCriteria(TmkCampania.class);
if(parametros[0].trim().length()>0 && Integer.parseInt(parametros[0])>=0){
criterios.add(Expression.eq("clUnegocio",new Integer(parametros[0])));
}
if(parametros[1].trim().length()>0 && Integer.parseInt(parametros[1])>0){
criterios.add(Expression.eq("flCampania",new Integer(parametros[1])));

}


return criterios.list();
}



and this is my test code :

public void testobtenDisCampania() throws HibernateException{
String[] args1 = {"0","1","-1"};

TmkCampaniaDAO admin = TmkCampaniaDAO.getInstance();
List lista = admin.obtenDisCampania(args1);
for (Iterator iter = lista.iterator(); iter.hasNext();) {
TmkCampania element = (TmkCampania) iter.next();
System.out.println("cve Unegocio:" + element.getClUnegocio());
System.out.println("Descripcion Campa


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 1:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
yes, it is an oracle bug

I think you can workaround by just mapping that column last in the mapping document


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 2:16 am 
Newbie

Joined: Mon Aug 02, 2004 12:11 pm
Posts: 10
Location: Mexico D.F.
Thanks for your fast reply, but i try it and :( i obtain the same error .... anything idea? , i try to quit the field and the method works fine ...but i need use that .... i'm sorry to bother you, but i have 3 days with this problem.

thanks again for your valuable help!
Regards


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 2:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
show the sql


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 2:35 am 
Newbie

Joined: Mon Aug 02, 2004 12:11 pm
Posts: 10
Location: Mexico D.F.
Here you are :

Hibernate: select this.FL_CAMPANIA as FL_CAMPA1_1_, this.CL_USR_MODIFICO as CL_USR_M2_1_, this.REMITENTE as REMITENTE1_, this.CL_ESTATUS as CL_ESTATUS1_, this.FE_VIG_INICIAL as FE_VIG_I5_1_, this.DIAS_ESPERA_CONTACTAR as DIAS_ESP6_1_, this.DS_CAMPANIA as DS_CAMPA7_1_, this.FG_ENVIO_MAIL as FG_ENVIO8_1_, this.FE_ULTMOD as FE_ULTMOD1_, this.FG_CONTACTAR as FG_CONT10_1_, this.DS_COMENTARIO as DS_COME11_1_, this.CL_TPCAMPANIA as CL_TPCA12_1_, this.ASUNTO as ASUNTO1_, this.FE_VIG_FINAL as FE_VIG_14_1_, this.DIAS_VIG_AGENDA as DIAS_VI15_1_, this.FL_ASEGUIMIENTO as FL_ASEG16_1_, this.CL_UNEGOCIO as CL_UNEG17_1_, this.FL_ADIFUSION as FL_ADIF18_1_, this.FL_GUION as FL_GUION1_, this.FL_GRUPO as FL_GRUPO1_, this.FL_TIPO_TAREA as FL_TIPO21_1_, this.TXT_MAIL as TXT_MAIL1_, tmkguion1_.FL_GUION as FL_GUION0_, tmkguion1_.FE_ULTMOD as FE_ULTMOD0_, tmkguion1_.CL_UNEGOCIO as CL_UNEGO3_0_, tmkguion1_.FG_ESTATUS as FG_ESTATUS0_, tmkguion1_.CL_USR_MODIFICO as CL_USR_M5_0_, tmkguion1_.DS_GUION as DS_GUION0_ from TMK_CAMPANIA this left outer join TMK_GUION tmkguion1_ on this.FL_GUION=tmkguion1_.FL_GUION where this.CL_UNEGOCIO=? and this.FL_CAMPANIA=?

Thanks again for your help Gavin.
Regards.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 2:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ok, disable the use of outer join fetching on the many-to-one associations (set lazy="true" on the associated classes)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 08, 2004 3:24 pm 
Newbie

Joined: Mon Aug 02, 2004 12:11 pm
Posts: 10
Location: Mexico D.F.
Hi Gavin, sorry if i didn't answer yesterday, it was very late to me but today i try this and i have other problem, i have a relation with other table where one field isn't named and de system send me a message like this :

No row with the given identifier exists : ixemkt.sd.catalogos.TMKAreaNegocioPK@7c218e,of class ixemkt.catalogos.TMKAreaNegocio

This is my HBM TMKCampania and the HBM with conflict, the columns where i want to relate are : CL_UNEGOCIO AND FL_ANEGOCIO where this column is equivalent to FL_ADIFUSION, why this fields are not the same name?? ...good question, the people that design my model must know why....

My problem in a nutshell is how do i do that in these relation :
FL_ADIFUSION=FL_ANEGOCIO in the mapping campAnegocio in class="TmkAreaNegocio" ?


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="ixemkt.sd.catalogos">
<class name="TmkCampania" table="TMK_CAMPANIA">
<id
column="FL_CAMPANIA"
name="flCampania"
type="integer"
>
<generator class="vm" />
</id>
<property
column="CL_USR_MODIFICO"
length="22"
name="clUsrModifico"
not-null="false"
type="integer"
/>
<property
column="REMITENTE"
length="80"
name="remitente"
not-null="false"
type="string"
/>
<property
column="CL_ESTATUS"
length="1"
name="clEstatus"
not-null="false"
type="integer"
/>
<property
column="FE_VIG_INICIAL"
length="7"
name="feVigInicial"
not-null="false"
type="date"
/>
<property
column="DIAS_ESPERA_CONTACTAR"
length="3"
name="diasEsperaContactar"
not-null="false"
type="integer"
/>
<property
column="DS_CAMPANIA"
length="80"
name="dsCampania"
not-null="false"
type="string"
/>
<property
column="FG_ENVIO_MAIL"
length="1"
name="fgEnvioMail"
not-null="false"
type="string"
/>
<property
column="FE_ULTMOD"
length="7"
name="feUltmod"
not-null="false"
type="date"
/>
<property
column="FG_CONTACTAR"
length="1"
name="fgContactar"
not-null="false"
type="string"
/>
<property
column="DS_COMENTARIO"
length="1024"
name="dsComentario"
not-null="false"
type="string"
/>
<property
column="CL_TPCAMPANIA"
length="2"
name="clTpcampania"
not-null="false"
type="integer"
/>
<property
column="ASUNTO"
length="80"
name="asunto"
not-null="false"
type="string"
/>
<property
column="FE_VIG_FINAL"
length="7"
name="feVigFinal"
not-null="false"
type="date"
/>
<property
column="DIAS_VIG_AGENDA"
length="3"
name="diasVigAgenda"
not-null="false"
type="integer"
/>
<property
column="FL_ASEGUIMIENTO"
name="flAseguimiento"
not-null="false"
type="integer"
/>
<property
column="CL_UNEGOCIO"
length="4"
name="clUnegocio"
not-null="true"
type="integer"
/>
<property
column="FL_ADIFUSION"
name="flAdifusion"
not-null="false"
type="integer"
/>
<property
column="FL_GUION"
name="flGuion"
not-null="false"
type="integer"
/>
<property
column="FL_GRUPO"
length="4"
name="flGrupo"
not-null="false"
type="integer"
/>
<property
column="FL_TIPO_TAREA"
name="flTipoTarea"
not-null="false"
type="integer"
/>
<!-- please tell Joe Hudson that the type 'LONG' could not be resolved.. defaulting to java.lang.String -->
<property
column="TXT_MAIL"
name="txtMail"
not-null="false"
type="java.lang.String"
/>
<many-to-one
name="empGuion"
class="TmkGuion"
insert="false"
update="false"
outer-join="false"
>
<column name="FL_GUION"/>
</many-to-one>
<many-to-one
name="empActividad"
class="TmkActividad"
insert="false"
update="false"
outer-join="false"
>
<column name="FL_TIPO_TAREA"/>
</many-to-one>
HERE IS THE CONFLICT, WITH FL_ADIFUSION THAT NOT EXIST IN TMKAREANEGOCIO
<many-to-one
class="TmkAreaNegocio"
insert="false"
name="campAnegocio"
not-null="true"
outer-join="false"
update="false"
>
<column name="CL_UNEGOCIO" />
<column name="FL_ADIFUSION" />
</many-to-one>

</class>
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="ixemkt.sd.catalogos">
<class
name="TmkAreaNegocio"
table="TMK_AREA_NEGOCIO"
>
<composite-id name="id" class="TmkAreaNegocioPK">
<key-property
name="flAnegocio"
column="FL_ANEGOCIO"
type="integer"
/>
<key-property
name="clUnegocio"
column="CL_UNEGOCIO"
type="integer"
/>
</composite-id>

<property
name="feUltmod"
column="FE_ULTMOD"
type="date"
not-null="false"
length="7"
/>
<property
name="fgEstatus"
column="FG_ESTATUS"
type="integer"
not-null="false"
length="1"
/>
<property
name="clUsrModifico"
column="CL_USR_MODIFICO"
type="integer"
not-null="false"
length="22"
/>
<property
name="fgRealizaDifSeg"
column="FG_REALIZA_DIF_SEG"
type="string"
not-null="false"
length="1"
/>
<property
name="nbAnegocio"
column="NB_ANEGOCIO"
type="string"
not-null="false"
length="10"
/>
<property
name="dsCorreoElectronico"
column="DS_CORREO_ELECTRONICO"
type="string"
not-null="false"
length="80"
/>
<property
name="fgAccesoInternet"
column="FG_ACCESO_INTERNET"
type="string"
not-null="false"
length="1"
/>
<property
name="dsAnegocio"
column="DS_ANEGOCIO"
type="string"
not-null="false"
length="80"
/>


</class>
</hibernate-mapping>

I'm very grateful with your help , thank you !!

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 20, 2004 3:10 pm 
Newbie

Joined: Mon Aug 02, 2004 12:11 pm
Posts: 10
Location: Mexico D.F.
Hi all, i resolved my problem , you should try to do something like this :

Example :

<many-to-one
name="campCatFijo"
class="TmkCatalogoFijo"
column="CL_TPCAMPANIA"
insert="false"
update="false"
>
<column name="FL_REGISTRO"/>
</many-to-one>


the field named CL_TPCAMPANIA is the field that i want to relate to table TmkCatalogofijo where the field that i want to match is FL_REGISTRO and it's work !!!

But if you have more fields this logic not works!! ....but why ?? ...i don't find it yet ...... have any ideas ??.

Regards


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