Olá pessoal! esttou com difiuldades no hibernate, naum consigo fazer um relacionamento de um-pra-muitos, vou explicar a situacao:
tenho duas tabelas: tx_texto e tx_texto_lingua, a tabela tx_texto tem um marcador, e a tabela tx_texto_lingua tem os textos traduzidos, ou seja, um texto tem varios tx_texto_lingua, eu fiz o seguinte mapeamento:
[quote]<class name=“bean.Texto” table=“tx_texto”>
<id name="id" column="id_texto">
<generator class="identity"/>
</id>
<many-to-one class="bean.Modulo" column="id_modulo" name="modulo" cascade="all"/>
<bag name="traducao" lazy="true" inverse="true" cascade="all">
<key column="id_texto"/>
<one-to-many class="bean.TextoLingua"/>
</bag>
<property name="texto" type="string" column="vc_texto"/>
<property name="cadastro" type="timestamp" column="dt_cadastro"/>
<property name="revisao" type="timestamp" column="dt_revisao"/>
</class>[/quote]
e quero frizar de que eu testei os objetos individualmente e eles estao ok, s´´o naum consigo carregar a lista de objetos TextoLingua dentro de Texto!! Pois acontece o seguinte erro:
[quote]Exception in thread “main” org.hibernate.exception.GenericJDBCException: could not initialize a collection: [bean.Texto.traducao#1]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2001)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:109)
at org.hibernate.collection.PersistentBag.size(PersistentBag.java:225)
at teste.TesteRelacionamento.main(TesteRelacionamento.java:34)
Caused by: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Índice de descritor inválido
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source)
at org.hibernate.type.IntegerType.get(IntegerType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
at org.hibernate.persister.collection.AbstractCollectionPersister.readKey(AbstractCollectionPersister.java:734)
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:975)
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:646)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:591)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
… 9 more[/quote]
[]s.