-->
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.  [ 7 posts ] 
Author Message
 Post subject: Same logical column name referenced several times
PostPosted: Fri Jan 20, 2006 6:04 am 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1.1

Mapping documents:

Code:
<?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>
  <class name="it.xxx.yyy7.model.AzioneStandard" table="AZIONE" entity-name="Azione">
    <id name="id" type="java.lang.Long" column="ID">
      <generator class="native" />
    </id>
    <property name="azienda" type="java.lang.String"
    column="AZIENDA" not-null="true" />
    <property name="codice" type="java.lang.String"
    column="CODICE" not-null="true" />
    <property name="descrizione" type="java.lang.String"
    column="DESCRIZIONE" />
    <property name="causale" type="java.lang.String"
    column="CAUSALE" />
    <property name="dislocazione" type="java.lang.String"
    column="DISLOCAZIONE" />
    <property name="ubicazione" type="java.lang.String"
    column="UBICAZIONE" />
    <property name="divisione" type="java.lang.String"
    column="DIVISIONE" />
    <property name="magazzino" type="java.lang.String"
    column="MAGAZZINO" />
    <property name="gestioneUdm" type="java.lang.String"
    column="GESTIONE_UDM" />
    <property name="gestioneUdc" type="java.lang.String"
    column="GESTIONE_UDC" />
    <property name="utCreazione" type="java.lang.String"
    column="UT_CREAZIONE" />
    <property name="utModifica" type="java.lang.String"
    column="UT_MODIFICA" />
    <property name="tsCreazione" type="java.sql.Timestamp"
    column="TS_CREAZIONE" />
    <property name="tsModifica" type="java.sql.Timestamp"
    column="TS_MODIFICA" />
   
    <many-to-one name="causaleObj" column="causale" entity-name="Causale"
                     property-ref="codice" insert="false"
                     update="false" lazy="false" outer-join="true" />       

  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close(): Not yet reached, exception during Configuration

Full stack trace of any exception that occurs:

Code:
org.hibernate.MappingException: Could not read mappings from resource: it/xxx/yyy/model/Azione.hbm.xml
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:484)
        at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1453)
        at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1421)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1402)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1378)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1298)
        at it.xxx.framework.services.HibernateService.<clinit>(HibernateService.java:42)
        at it.xxx.framework.beans.HibernateBeanDAO.getSession(HibernateBeanDAO.java:80)
        at it.xxx.framework.beans.HibernateBeanDAO.prepareStatement(HibernateBeanDAO.java:356)
        at it.xxx.framework.beans.BeanManager.prepareStatement(BeanManager.java:394)
        at it.xxx.yyy.manager.OperazioneManager.getElencoOperazioni(OperazioneManager.java:13)
        at it.zzz.yyy.services.OperazioneArticoloService.getElencoOperazioni(OperazioneArticoloService.java:96)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at it.xxx.framework.rpc.RPCServlet.processRequest(RPCServlet.java:73)
        at it.xxx.framework.rpc.RPCServlet.doPost(RPCServlet.java:18)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.MappingException: Same logical column name referenced several times: AZIONE.causale CAUSALE causale
        at org.hibernate.cfg.Mappings.addColumnBinding(Mappings.java:457)
        at org.hibernate.cfg.HbmBinder.bindColumns(HbmBinder.java:1075)
        at org.hibernate.cfg.HbmBinder.bindColumnsOrFormula(HbmBinder.java:1495)
        at org.hibernate.cfg.HbmBinder.bindManyToOne(HbmBinder.java:1507)
        at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2028)
        at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1998)
        at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:361)
        at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:275)
        at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:146)
        at org.hibernate.cfg.Configuration.add(Configuration.java:385)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:426)
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:481)


Name and version of the database you are using: DB2/400 V5R3

The generated SQL (show_sql=true): None

Debug level Hibernate log excerpt: Not yet registered, will provide if useful


Hi,

I got this exception when I updated Hibernate 3.1 to 3.1.1.

I probably made a mistake in my mapping file which wasn't caught in 3.1.

But I don't see where it is, anyone can suggest ?


Thanks,

Giulio


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 6:39 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Just a guess but please try using the tableName.column name both places you have
Code:
column="causale"


E.g.
Code:
column="azione.causale"


and
Code:
column="causale.causale"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 7:04 am 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
Thanks Tim, that was it.

I modified the mapping so that in the <many-to-one> section the column attribute is "AZIONE.CAUSALE".

The peculiarity of my mapping is that the many-to-one referenced object (Causale, in this case) has the key column mapped both as a normal column and as an object.

It wouldn't be necessary to do so, because the key column is accessible also on the referenced object, but I often have the need to just obtain the key of the possessed object without retrieving it.


Hope this helps anyone who has a similar problem when upgrading.


Giulio


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 7:31 am 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
Actually, something is still wrong.

Hibernate loaded the hbm files, but the generated SQL is different now.

Code:
12:22:18,233 DEBUG [SQL] select operazione0_.ID as ID9_, operazione0_.AZIENDA as AZIENDA9_, operazione0_.CODICE as CODICE9_, ope
razione0_.DESCRIZIONE as DESCRIZI4_9_, operazione0_.DESC_BREVE as DESC5_9_, operazione0_.TIPO_CODICE as TIPO6_9_, operazione0_.A
ZIONE1 as AZIONE7_9_, operazione0_.AZIONE2 as AZIONE8_9_, operazione0_.AZIONE3 as AZIONE9_9_, operazione0_.AZIONE4 as AZIONE10_9
_, operazione0_.OPER_GUIDATA as OPER11_9_, operazione0_.UT_CREAZIONE as UT12_9_, operazione0_.UT_MODIFICA as UT13_9_, operazione
0_.TS_CREAZIONE as TS14_9_, operazione0_.TS_MODIFICA as TS15_9_, operazione0_.OPERAZIONE.AZIONE1 as OPERAZIONE16_9_, operazione0
_.OPERAZIONE.AZIONE2 as OPERAZIONE17_9_, operazione0_.OPERAZIONE.AZIONE3 as OPERAZIONE18_9_, operazione0_.OPERAZIONE.AZIONE4 as
OPERAZIONE19_9_ from OPERAZIONE operazione0_ order by operazione0_.CODICE


Four clauses were added, like this :

Code:
operazione0_.OPERAZIONE.AZIONE1 as OPERAZIONE16_9_


In my environment the query fails becuase operazione... is too long for DB2/400, but I think it's wrong anyway.

Obviously the .OPERAZIONE. in the middle is not needed, but I understand that I specified in the hbm to do so. I didn't think it would re-query those four columns.

In version 3.1 I didn't have this issue.

I still believe that it's an error in my mapping file (in the first post), just don't find it.

Giulio


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 7:33 am 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
Sorry, this is the mapping file the error is referred to.

Code:
<?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>
  <class name="it.xxx.yyy.model.OperazioneStandard" table="OPERAZIONE" entity-name="Operazione">
    <id name="id" type="java.lang.Long" column="ID">
      <generator class="native" />
    </id>
    <property name="azienda" type="java.lang.String" column="AZIENDA" not-null="true" />
    <property name="codice" type="java.lang.String" column="CODICE" not-null="true"  />
    <property name="descrizione" type="java.lang.String" column="DESCRIZIONE" />
    <property name="descBreve" type="java.lang.String" column="DESC_BREVE"  />
    <property name="tipoCodice" type="java.lang.String" column="TIPO_CODICE"  />
    <property name="azione1" type="java.lang.String" column="AZIONE1"  />
    <property name="azione2" type="java.lang.String" column="AZIONE2"  />
    <property name="azione3" type="java.lang.String" column="AZIONE3"  />
    <property name="azione4" type="java.lang.String" column="AZIONE4"  />
    <property name="operGuidata" type="java.lang.String" column="OPER_GUIDATA"  />
    <property name="utCreazione" type="java.lang.String" column="UT_CREAZIONE"  />
    <property name="utModifica" type="java.lang.String" column="UT_MODIFICA"  />
    <property name="tsCreazione" type="java.sql.Timestamp" column="TS_CREAZIONE" not-null="true"  />
    <property name="tsModifica" type="java.sql.Timestamp" column="TS_MODIFICA" not-null="true"  />

    <many-to-one name="azione1Obj" column="OPERAZIONE.AZIONE1" entity-name="Azione"
                     property-ref="codice" insert="false"
                     update="false" lazy="false" outer-join="true" />       

    <many-to-one name="azione2Obj" column="OPERAZIONE.AZIONE2" entity-name="Azione"
                     property-ref="codice" insert="false"
                     update="false" lazy="false" outer-join="true" />       
                     
    <many-to-one name="azione3Obj" column="OPERAZIONE.AZIONE3" entity-name="Azione"
                     property-ref="codice" insert="false"
                     update="false" lazy="false" outer-join="true" />       
                     
    <many-to-one name="azione4Obj" column="OPERAZIONE.AZIONE4" entity-name="Azione"
                     property-ref="codice" insert="false"
                     update="false" lazy="false" outer-join="true" />       

  </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 9:16 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Hey, not got too much time too look right now but I tried to do many-to-many joins using property-ref="XYZ" and couldn't get it to work - I read a few posts about there possibly being a bug but in the end I changed my model to use PK references instead. Try searching around the forum for property-ref. Hope this produces some leads for you - good luck


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 9:21 am 
Regular
Regular

Joined: Tue Oct 26, 2004 3:54 pm
Posts: 60
Yes, surely our discussion clarified the problem.

Actually I guess that many users won't notice this behaviour, because more natural mappings may not reproduce it.

I reverted back to 3.1 while I try to understand how to properly map my files (or eventually discover that this is a defect introduced in 3.1.1).

Changing my mapping files is not an option, and besides that, I think I can live with 3.1 for now.


Regards,

Giulio


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