-->
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: 453 ERROR JDBCExceptionReporter:72 - Unknown column
PostPosted: Thu Oct 13, 2011 5:21 pm 
Newbie

Joined: Sat Oct 01, 2011 11:28 am
Posts: 6
Hi, I have a problem in a query with multiple join
this is my query:
Code:
select pv.azienda,tcl.testo,t.testo from tc_par t,rel_pv_par rel_pv_par,tc_clpar tcl ,pv  pv where t.id=rel_pv_par.tc_par_id  and t.tc_clpar_id=tcl.tc_clpar_id  and rel_pv_par.pv_id=pv.id and pv.id=795

this is my hibernate mapping file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="">
  <!-- Database connection settings -->
  <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  <property name="connection.url">jdbc:mysql://localhost:3306/parafarmacie</property>
  <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  <property name="connection.username">root</property>
  <property name="connection.password">vilu7240</property>
  <!-- JDBC connection pool (use the built-in) -->
  <property name="connection.pool_size">2</property>
  <!-- SQL dialect
Enable Hibernate's automatic session context management -->
  <property name="current_session_context_class">thread</property>
  <!-- Disable the second-level cache -->
  <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
  <!-- Echo all executed SQL to stdout -->
  <property name="show_sql">false</property>
  <mapping class="entita.Pv" resource="entita/Pv.hbm.xml"/>
  <mapping class="entita.Tc_par" resource="entita/Tc_par.hbm.xml"/>
  <mapping class="entita.Rel_pv_par" resource="entita/rel_pv_par.hbm.xml"/>
  <mapping class="entita.Tc_pot" resource="entita/tc_pot.hbm.xml"/>
  <mapping class="entita.Tc_clpot" resource="entita/tc.clpot.hbm.xml"/>
  <mapping class="entita.Rel_pv_pot" resource="entita/rel_pv_pot.hbm.xml"/>
  <mapping class="entita.Tc_cl_par" resource="entita/tc_cl_par.hbm.xml"/>
  <mapping class="entita.Tc_clpar" resource="entita/tc_clpar.hbm.xml"/>
</session-factory>
</hibernate-configuration>


and the entities I use in this query

1) tc_par.hbm.xml
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 entity-name="tc_par" name="entita.Tc_par" table="tc_par">
  <id column="tc_par_id" name="id">
   <generator class="assigned"/>
  </id>

<property column="tc_clpar_id" name="tc_clpar_id" type="long"></property>
<property column="tc_stato_id" name="tc_stato_id" type="long"></property>
<property column="testo" name="testo" type="string"></property>
<property column="ordine" name="ordine" type="long"></property>
<property column="ins_data" name="ins_data" type="date"></property>
<property column="mod_utente"  name="mod_utente" type="date"></property>
<property column="mod_data"  name="mod_data" type="date"></property>
<property column="ins_utente"  name="ins_utente" type="date"></property>
      
</class>
</hibernate-mapping>




2) rel_pv_par.hbm.xml
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 entity-name="rel_pv_par" name="entita.Rel_pv_par" table="tc_par">


<composite-id>
       
       
        <key-property name="pv_id" column="pv_id" type="long" />
        <key-property name="tc_par_id" column="tc_par_id" type="long"/>
     
       





  </composite-id>

<property column="tc_clpar_id" name="tc_clpar_id" type="long"></property>
<property column="ins_data" name="ins_data" type="date"></property>
<property column="mod_utente"  name="mod_utente" type="date"></property>
<property column="mod_data"  name="mod_data" type="date"></property>
<property column="ins_utente"  name="ins_utente" type="date"></property>
      
</class>
</hibernate-mapping>

3) tc_clpar.hbm.xml
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 entity-name="tc_clpar" name="entita.Tc_par" table="tc_clpar">
  <id column="tc_clpar_id" name="tc_clpar_id">
   <generator class="assigned"/>
  </id>

<property column="tc_stato_id" name="tc_stato_id" type="long"></property>
<property column="testo" name="testo" type="string"></property>
<property column="ordine" name="ordine" type="long"></property>
<property column="ins_data" name="ins_data" type="date"></property>
<property column="mod_utente"  name="mod_utente" type="date"></property>
<property column="mod_data"  name="mod_data" type="date"></property>
<property column="ins_utente"  name="ins_utente" type="date"></property>
      
</class>
</hibernate-mapping>



4) pv.hbm.xml

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 entity-name="pv" name="entita.Pv" table="pv">
  <id column="pv_id" name="id">
   <generator class="assigned"/>
  </id>
  <property column="nome1" generated="never" lazy="false" name="azienda" type="string"/>
  <property column="nome2" name="titolare" type="string"/>
</class>
</hibernate-mapping>



this is the error I got from eclipse

Quote:

453 ERROR JDBCExceptionReporter:72 - Unknown column 'rel_pv_par1_.pv_id' in 'where clause'
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query using iterate
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:420)
at org.hibernate.hql.ast.QueryTranslatorImpl.iterate(QueryTranslatorImpl.java:318)
at org.hibernate.engine.query.HQLQueryPlan.performIterate(HQLQueryPlan.java:177)
at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1156)
at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:46)
at PvSelect.parametri(PvSelect.java:82)
at PvSelect.main(PvSelect.java:233)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'rel_pv_par1_.pv_id' in 'where clause'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2625)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
at org.hibernate.loader.hql.QueryLoader.iterate(QueryLoader.java:397)
... 6 more


the rel_pv_parl_.pv_id should be rel_pv_par.pv_id, the table rel_pv_parl_ do not even exist, I am new at Hibernate and do not understand what is wrong with my code, any help appreciated thanks in advance.


Top
 Profile  
 
 Post subject: Re: 453 ERROR JDBCExceptionReporter:72 - Unknown column
PostPosted: Fri Oct 14, 2011 1:03 pm 
Newbie

Joined: Thu Oct 13, 2011 2:01 pm
Posts: 2
I've been through this problem!
Check the uppercase and lowercase characters in both. HBM and in class.


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.