-->
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.  [ 2 posts ] 
Author Message
 Post subject: Many-to-many with formula tag
PostPosted: Tue Nov 18, 2008 9:48 am 
Newbie

Joined: Tue Nov 18, 2008 9:03 am
Posts: 2
Hi,

I´m trying to map a many-to-many relantioship, with the <formula> tag:


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="br.com.actumplus.act500.model.faturamento">
<class name="Duplicata" table="FATURA_DUPLICATA">
<composite-id access="field" class="DuplicataID" mapped="false"
name="duplicataID" unsaved-value="undefined">

<key-property column="cod_orgao" name="codigoOrgao" type="java.lang.String"/>
<key-property column="num_ano_fatura" name="numeroAnoFatura" type="java.lang.Integer"/>
<key-property column="num_fatura" name="numeroFatura" type="java.lang.Integer"/>
<key-property column="num_duplic" name="numeroDuplicata" type="java.lang.Integer"/>

</composite-id>
<property column="dat_vencto_duplic" generated="never" lazy="false"
name="dataVencimento" type="java.util.Date"/>
<property column="val_duplic" generated="never" lazy="false"
name="valorDuplicata" type="java.lang.Double"/>
<property column="dat_hora_emissa" generated="never" lazy="false"
name="dataHoraEmissao" type="java.util.Date"/>

<set name="titulosAReceber" inverse="true" table="REL_FATURA_DUP_TITULO_REC">
<key>
<column name="cod_orgao" sql-type="java.lang.String"></column>
<column name="num_ano_fatura"></column>
<column name="num_fatura"></column>
<column name="num_duplic"></column>
</key>
<many-to-many entity-name="br.com.actumplus.act500.model.faturamento.TituloReceber">
<column name="num_ano_recebe"></column>
<column name="num_titulo_recebe"></column>
<formula>cod_orgao</formula>
</many-to-many>
</set>

</class>
</hibernate-mapping>


The cod_orgao is a varchar column. Both sides of many-to-many can be loaded with no problem isolated.

When I try to load the collection I have the error:

org.hibernate.exception.DataException: could not initialize a collection: [br.com.actumplus.act500.model.faturamento.Duplicata.titulosAReceber#component[codigoOrgao,numeroAnoFatura,numeroFatura,numeroDuplicata]{codigoOrgao=ACT, numeroFatura=1, numeroDuplicata=11, numeroAnoFatura=2008}]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100)
...

caused by:
org.postgresql.util.PSQLException: Valor inválido para tipo int : ACT (ACT is Not an valid int)

and a INFO: 2008-11-18 11:35:54,421 INFO [org.hibernate.type.IntegerType] could not read column value from result set: formula0_1_; Valor inválido para tipo int : ACT

Has someone seen this problem before?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 6:56 am 
Newbie

Joined: Tue Nov 18, 2008 9:03 am
Posts: 2
Problem solved.

The problem was the key order. It was mapped a, then b, then c in its xml. And mapped b, then c, then a, as foreign key.

The order must be the same.


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