-->
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: component mapping problem
PostPosted: Fri Jul 29, 2005 10:02 am 
Newbie

Joined: Fri Jul 08, 2005 4:40 am
Posts: 8
im trying to correctly map 2 classes: PropostaOrdine and Ordine
Ordine is a component of PropostaOrdine (the relation between the 2 obj is one-to-one)

*LOY_RIC_ORDINE (class: PropostaOrdine)

C_CMP (PK)(FK)
N_PRG_RIC_ORD(PK)
C_COD_ORD(FK)

*LOY_ORDINE (class: Ordine)

C_CMP (PK)
C_COD_ORD(PK)


when hib queries the db for instantiating a PropostaOrdine obj it
assigns values to its properties too; as one of PropostaOrdine’s properties
happens to be another java obj (Ordine in this case) i expect it to create an Ordine obj, asssign values to Ordine’s properties and assign that obj to PropostaOrdine
(hope my description is clear .. sorry for my bad english)
but that doesn’t happen .. so im trying to fix it and figure out more about hib mappings

any help will be greatly appreciated :D


Hibernate version:
2.1

Mapping documents:
<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" type="string" column="C_CMP" />
<key-property name="prg" type="int" column="N_PRG_RIC_ORD" />
</composite-id>

<property name="stato" type="string" column="C_STA_RIC" />

<property name="tipo" type="string" column="C_TIP_ORD" />

<property name="codOrd" type="string" column="C_COD_ORD" />

<component name="ordine" class="fuckthegest.model.Ordine">
<property name="cmp" />
<property name="codOrd" />
</component>

</class>

<query name="fuckthegest.model.findPo">
<![CDATA[
from fuckthegest.model.PropostaOrdine as po
where po.cmp = :cmp and po.prg = :prg
]]>
</query>

</hibernate-mapping>



<hibernate-mapping>

<class name="fuckthegest.model.Ordine" table="LOY_ORDINE">

<composite-id>
<key-property name="cmp" type="string" column="C_CMP" />
<key-property name="codOrd" type="string" column="C_COD_ORD" />
</composite-id>

<property name="stato" type="string" column="C_STA_ORD" />

</class>

</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Query query = session.getNamedQuery("fuckthegest.model.findPo");

query.setString("cmp", cmp);
query.setInteger("prg", prg);

po = (PropostaOrdine)query.uniqueResult();

Full stack trace of any exception that occurs:

[2005-07-29 0324:18]ERROR[http-8080-Processor25](PoSelectAction.java:58) - 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.manager.ManagePropostaOrdine.select(ManagePropostaOrdine.java:35)
at fuckthegest.web.po.PoSelectAction.execute(PoSelectAction.java:46)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
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.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.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: ORA-00904: invalid column name

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:880)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2516)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2850)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:537)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1554)
... 24 more

Name and version of the database you are using:

oracle

The generated SQL (show_sql=true):

select propostaor0_.C_CMP as C_CMP,
propostaor0_.N_PRG_RIC_ORD as N_PRG_RI2_,
propostaor0_.C_STA_RIC as C_STA_RIC,
propostaor0_.C_TIP_ORD as C_TIP_ORD,
propostaor0_.C_COD_ORD as C_COD_ORD,
propostaor0_.cmp as cmp, propostaor0_.codOrd as codOrd
from LOY_RIC_ORDINE propostaor0_
where (propostaor0_.C_CMP=? ) and (propostaor0_.N_PRG_RIC_ORD=? )

shouldnt it be a join query with LOY_RIC_ORDINE and LOY_ORDINE ?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 31, 2005 7:47 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
per
http://www.hibernate.org/hib_docs/v3/re ... n-onetoone

default value for lazy is proxy.

Try setting lazy=false explicitly


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.