-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping collection
PostPosted: Fri Mar 31, 2006 6:17 pm 
Newbie

Joined: Fri Mar 31, 2006 5:10 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hi, I´m having a trouble when I tried to access a collection, and I am not seeing the error follow de mapping. and the execption

Hibernate version: 3.0

Mapping documents:

PROCESSO has a collection of Encaminhamento
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="br.com.faculdadejk.VO">
<class name="Processo" table="processo">
<id name="id" column="id">
<generator class="increment" />
</id>

<property name="dataCadastro" column="data_cadastro" type="java.util.Date" />
<property name="dataSetor" column="data_setor" type="java.util.Date" />
<property name="detalhes" column="detalhes" type="java.lang.String" />
<property name="matricula" column="matricula" type="java.lang.String"/>
<set name="documentos" lazy="true" inverse="true">
<key column="processo_id" />
<one-to-many class="Documento" />
</set>


<set name="encaminhamentos" lazy="true" inverse="true">
<key column="processo_id"/>
<one-to-many class="Encaminhamento"/>
</set>


<many-to-one name="usuario" column="usuario_id" class="Usuario" not-null="true"/>

</class>
</hibernate-mapping>


ENCAMINHAMENTO
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="br.com.faculdadejk.VO">
<class name="Encaminhamento">
<id name="id" column="id" type="int">
<generator class="increment"/>
</id>

<property name="dataEnvio" column="data_Envio"/>
<property name="parecer" column="parecer"/>

<many-to-one name="processo" column="PROCESSO_id" not-null="true"/>

<many-to-one name="usuarioOrigem" column="usuario_id_Origem" class="Usuario"/>
<many-to-one name="usuarioDestino" column="usuario_id_destino" class="Usuario"/>

</class>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():

Transaction tx = session.beginTransaction();
Processo processo = (Processo) session.get(Processo.class,new Integer(290));
System.out.println(processo.getMatricula());
if(processo.getEncaminhamentos().isEmpty())
System.out.print("Vazio");


tx.commit();

Full stack trace of any exception that occurs:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select processo0_.id as id0_, processo0_.data_cadastro as data2_0_0_, processo0_.data_setor as data3_0_0_, processo0_.detalhes as detalhes0_0_, processo0_.matricula as matricula0_0_, processo0_.usuario_id as usuario6_0_0_ from processo processo0_ where processo0_.id=?
07-05390
Hibernate: select encaminham0_.processo_id as processo7_1_, encaminham0_.id as id1_, encaminham0_.id as id0_, encaminham0_.data_Envio as data2_1_0_, encaminham0_.parecer as parecer1_0_, encaminham0_.PROCESSO_id as PROCESSO4_1_0_, encaminham0_.usuario_id_Origem as usuario5_1_0_, encaminham0_.usuario_id_destino as usuario6_1_0_ from Encaminhamento encaminham0_ where encaminham0_.processo_id=?
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not initialize a collection: [br.com.faculdadejk.VO.Processo.encaminhamentos#290] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1441)
at org.hibernate.loader.collection.OneToManyLoader.initialize(OneToManyLoader.java:111)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1430)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:176)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48)
at org.hibernate.collection.PersistentSet.isEmpty(PersistentSet.java:118)
at br.com.faculdadejk.VO.Main.main(Main.java:25)
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 1. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.validateColumnIndex(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.getInt(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.getInt(Unknown Source)
at org.hibernate.type.IntegerType.get(IntegerType.java:26)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.persister.collection.AbstractCollectionPersister.readKey(AbstractCollectionPersister.java:633)
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:648)
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:370)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:314)
at org.hibernate.loader.Loader.doQuery(Loader.java:412)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1434)
... 8 more


Name and version of the database you are using:

The generated SQL (show_sql=true):
MSSQL 2000


Please I dont found the error. HELLP MEEEEEEEEEEE


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

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.