-->
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: Two one-to-one relation in the same class error
PostPosted: Thu Mar 30, 2006 10:40 am 
Newbie

Joined: Mon Sep 27, 2004 6:39 am
Posts: 5
Hibernate version:3.1

Full stack trace of any exception that occurs:SQLGrammarException: Colud not load an entity (BeanMessaggio#1)

Name and version of the database you are using:MySql 4.1

The generated SQL (show_sql=true):Errore nella query: org.hibernate.exception.SQLGrammarException: could not load an entity: [it.publisys.gestionecommesse.modello.BeanMessaggio#1]



I have two bean: BeanMessaggio and BeanRichiestaIntervento.

BeanMessaggio:
<?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 default-lazy="false">
<class name="it.publisys.gestionecommesse.modello.BeanMessaggio"
table="messaggio" >
<id column="id" name="id" type="integer">
<generator class="native"/>
</id>
<one-to-one name="beanRichiestaIntervento" class="it.publisys.gestionecommesse.modello.BeanRichiestaIntervento" property-ref="beanMessaggio" />
<one-to-one name="beanRispostaIntervento" class="it.publisys.gestionecommesse.modello.BeanRispostaIntervento" property-ref="beanMessaggio" />
<!--one-to-one name="beanRichiestaFattibilita" class="it.publisys.gestionecommesse.modello.BeanRichiestaFattibilita" property-ref="beanMessaggio" /-->
<!--one-to-one name="beanRispostaFattibilita" class="it.publisys.gestionecommesse.modello.BeanRispostaFattibilita" property-ref="beanMessaggio" />
<one-to-one name="beanIntervento" class="it.publisys.gestionecommesse.modello.BeanIntervento" property-ref="beanMessaggio"/-->

</class>
</hibernate-mapping>


BeanRichiestaIntervento:

<?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 default-lazy="false">
<class name="it.publisys.gestionecommesse.modello.BeanRichiestaIntervento" table="richiestaintervento" >

<id column="id" name="id" type="integer">
<generator class="native"/>
</id>
<property name="descrizioneRichiesta" column="descrizioneRichiesta" type="string" />
<property name="oggettoRichiesta" column="oggettoRichiesta" type="string" />
<property name="inviata" column="inviata" type="boolean" />
<property name="dataRichiesta" column="dataRichiesta" type="date" />
<many-to-one name="beanMessaggio" class="it.publisys.gestionecommesse.modello.BeanMessaggio" column="idMessaggio" unique ="true"/>
<!--one-to-one name="beanMessaggio" class="it.publisys.gestionecommesse.modello.BeanMessaggio" property-ref="beanRichiestaIntervento" /-->
<many-to-one name="beanUtente" class="it.publisys.gestionecommesse.modello.BeanUtente" column="idUtente" unique ="true"/>
</class>
</hibernate-mapping>


When in BeanMessagio there are two one-to-one association the load of the BeanMessagio give me follow error: org.hibernate.exception.SQLGrammarException: could not load an entity: [it.publisys.gestionecommesse.modello.BeanMessaggio#1].
Why?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 11:23 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I'm surprised that one-to-one property-ref="xxx" is now allowed in 3.1, as I thought the reasons for not allowing it before were good.

Can you post the full exception trace? It's likely that the problem is due to having one-to-one mappings when many-to-one unique="true" is more appropriate. You could also try changing the one-to-ones, see if it helps.


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.