-->
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.  [ 6 posts ] 
Author Message
 Post subject: hibernate query problem
PostPosted: Fri Jul 08, 2005 4:45 am 
Newbie

Joined: Fri Jul 08, 2005 4:40 am
Posts: 8
was quite happy cause hibernate successfully mapped my class to the db
when i tried to execute a query and got a sql invalid column name error!!
but im sure i mapped the class's field to the correct column name

<property name="cmp" type="string" column="C_CMP" not-null="true"/>

this is the query:
from fuckthegest.model.PropostaOrdine as po where po.cmp = :cmp and po.prg = :prg

i cant figure this out

does anybody have a useful clue??

thank u (please.....)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 6:15 am 
Newbie

Joined: Fri Jul 08, 2005 4:40 am
Posts: 8
some info from my log:

[2005-07-08 1224:04]WARN [http-8080-Processor25](JDBCExceptionReporter.java:57) - SQL Error: 904, SQLState: 42000
[2005-07-08 1224:04]ERROR[http-8080-Processor25](JDBCExceptionReporter.java:58) - ORA-00904: invalid column name

[2005-07-08 1224:04]ERROR[http-8080-Processor25](PoSelectAction.java:55) - Could not execute query
net.sf.hibernate.exception.SQLGrammarException: Could not execute query
at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1557)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)
at net.sf.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:550)
at fuckthegest.model.ManagePropostaOrdine.select(ManagePropostaOrdine.java:37)
at fuckthegest.web.PoSelectAction.execute(PoSelectAction.java:45)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 7:00 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
You need to provide more information and turn on sql output.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 7:51 am 
Newbie

Joined: Fri Jul 08, 2005 4:40 am
Posts: 8
hib generated query (ugly... :D )

select propostaor0_.cmp as cmp, propostaor0_.prg as prg,
propostaor0_.C_CMP as C_CMP,
propostaor0_.N_PRG_RIC_ORD as N_PRG_RI4_,
propostaor0_.C_STA_RIC as C_STA_RIC,
propostaor0_.C_TIP_ORD as C_TIP_ORD
from LOY_RIC_ORDINE propostaor0_
where (propostaor0_.cmp=? )and(propostaor0_.prg=? )


propostaor0_.cmp
propostaor0_.prg
are not valid column names, they are named C_CMP and N_PRG_RIC_ORD
so why hib does that??

im posting the mapping doc too
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
               PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
               "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>

   <class name="fuckthegest.model.PropostaOrdine" table="LOY_RIC_ORDINE">
      <meta attribute="class-description">
         Represents a single proposta d' ordine.         
      </meta>            
            
      <composite-id>         
         <key-property name="cmp" />
         <key-property name="prg" />
      </composite-id>      
            
      <property name="cmp" type="string" column="C_CMP" not-null="true"/>
      
      <property name="prg" type="int" column="N_PRG_RIC_ORD" />
      
      <property name="stato" type="string" column="C_STA_RIC" />
      
      <property name="tipo" type="string" column="C_TIP_ORD" />
      
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 8:35 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
well ... i'm no expert in using hibernate ... but if i were you, i would start reading the docs an learn how to make a hibernate-mapping.

Your mapping seams to be wrong (in my eyes) ... especially the "key-property" - mapping ...

No, not more help ... because this is answerd 1000 times in this forum and in the docs ... just a hint ...

gtx
curio


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 08, 2005 9:56 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Read the documentation, especially chapter 6.1.5 (composite-id). You will recognize that the element <key-property> also contains an attribute "column".

Best regards
Sven


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