-->
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.  [ 9 posts ] 
Author Message
 Post subject: Outer join without association
PostPosted: Fri Mar 07, 2008 6:45 am 
Newbie

Joined: Fri Mar 07, 2008 6:37 am
Posts: 4
Hi,

I was wondering if it is possible to make an outer-join without defining any association in my mapping.

The issue we have is that most of the association we need are dynamical.
So we do not want to hard code them in a mapping file . (there would be too many)


here is an example of what we want to do:

select PARC.id, TRADFIC.libelle from SdbParc PARC
right outer join SdbTradfic TRAFIC
on TRADFIC.code = PARC.code



Thanks for your help.


Top
 Profile  
 
 Post subject: Re: Outer join without association
PostPosted: Fri Mar 07, 2008 10:19 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Do you mean you want to give a sql everytime you need to fetch an association? If so, then you need not to map the association but the target entities and always use hql or sql to retrieve them and that means you are going to handle a lot more than a regular HB user and you won't benefit much from hibernate.


Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 10:57 am 
Newbie

Joined: Fri Mar 07, 2008 6:37 am
Posts: 4
Yes,

But the thing is that hibernate tells me my request in wrong
because there is no attribute tradfic in my mapping Parc.


So I was wondering if it is possible to avoid such a hard coded association.


Seeing your answer I suppose no ..


Last edited by carsystems on Fri Mar 07, 2008 11:23 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 10:59 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
carsystems wrote:
Yes,

But the thing is that hibernate tells me my request in wrong
because there is no attribute para in my mapping Parc.


So I was wondering if it is possible to avoid such a hard coded association.


Seeing your answer I suppose no ..


What is para? Give me an example that does not work.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 11:48 am 
Newbie

Joined: Fri Mar 07, 2008 6:37 am
Posts: 4
not working Example:
Code:
select PARC.cle.codeParc, TRADFIC.texte from biz.carsystems.noyau.db.DbParc PARC
right outer join biz.carsystems.noyau.db.DbTradfic TRAFIC
on TRADFIC.cle.nomFichier = "PARC" and TRADFIC.cle.codeZone = PARC.cle.codeMarque



Here you have 2 tables with no association in the mapping files. On which we want to apply a outer join.




mapping of table PARC
Code:

  <class dynamic-update="true" name="biz.carsystems.noyau.db.DbParc" table="`PARC`" optimistic-lock="none">
    <cache usage="read-write" />
    <composite-id name="cle" class="biz.carsystems.noyau.db.DbParcPK">
      <key-property name="codeParc" column="`codeParc`" type="biz.carsystems.noyau.lang.CsTexte" />
    </composite-id>
    <property name="libelleLong" type="biz.carsystems.noyau.lang.CsTexte" not-null="false">
      <column name="`libelleLong`" sql-type="varchar" />
    </property>
    <property name="immat" type="biz.carsystems.noyau.lang.CsTexte" not-null="false">
      <column name="`immat`" sql-type="varchar" />
    </property>
    <property name="dateImmat" type="biz.carsystems.noyau.lang.CsDate" not-null="false">
      <column name="`dateImmat`" sql-type="date" />
    </property>
    <property name="codeMarque" type="biz.carsystems.noyau.lang.CsTexte" not-null="false">
      <column name="`codeMarque`" sql-type="varchar" />
    </property>
    <property name="codeModele" type="biz.carsystems.noyau.lang.CsTexte" not-null="false">
      <column name="`codeModele`" sql-type="varchar" />
    </property>
    <property name="catTarif" type="biz.carsystems.noyau.lang.CsTexte" not-null="false">
      <column name="`catTarif`" sql-type="varchar" />
    </property>

  </class>


mapping of Trafic

Code:
  <class dynamic-update="true" name="biz.carsystems.noyau.db.DbTradfic" table="`TRADFIC`" optimistic-lock="none">
    <cache usage="read-write" />
    <composite-id name="cle" class="biz.carsystems.noyau.db.DbTradficPK">
      <key-property name="nomFichier" column="`nomFichier`" type="biz.carsystems.noyau.lang.CsTexte" />
      <key-property name="cleEnreg" column="`cleEnreg`" type="biz.carsystems.noyau.lang.CsTexte" />
      <key-property name="codeZone" column="`codeZone`" type="biz.carsystems.noyau.lang.CsTexte" />
      <key-property name="langue" column="`langue`" type="biz.carsystems.noyau.lang.CsTexte" />
    </composite-id>
    <property name="texte" type="biz.carsystems.noyau.lang.CsTexte" not-null="false">
      <column name="`texte`" sql-type="varchar" />
    </property>
  </class>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 11:54 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
and what exactly is HB complaining? Show me the exception if there is an exception.




Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 12:02 pm 
Newbie

Joined: Fri Mar 07, 2008 6:37 am
Posts: 4
The exeception is:
Quote:
net.sf.hibernate.QueryException: outer or full join must be followed by path expression
at net.sf.hibernate.hql.FromParser.token(FromParser.java:166)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:295)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1572)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1602)
at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:29)
at biz.carsystems.noyau.manager.cnx.HibernateConnexion$RqtHibernate2.select(HibernateConnexion.java:2473)
at biz.carsystems.noyau.manager.cnx.HibernateConnexion.select(HibernateConnexion.java:340)
at biz.carsystems.noyau.ejb.CsBaseAccess.select(CsBaseAccess.java:1598)
at biz.carsystems.noyau.ejb.CsBaseAccess.select(CsBaseAccess.java:1536)
at biz.carsystems.noyau.ejb.EjbCtrGenBean.select(EjbCtrGenBean.java:1239)
at biz.carsystems.noyau.ejb.EjbCtrGenBean.select(EjbCtrGenBean.java:1093)
at biz.carsystems.noyau.ejb.EjbCtrGenBean.select(EjbCtrGenBean.java:1079)
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:324)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
at org.jboss.ejb.plugins.AbstractInterceptor.invoke(AbstractInterceptor.java:94)
at org.jboss.ejb.plugins.MetricsInterceptor.invoke(MetricsInterceptor.java:114)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:144)
at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
at org.jboss.ejb.Container.invoke(Container.java:709)
at sun.reflect.GeneratedMethodAccessor114.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)



A full path is not possible does not have any hardcoded association with Tradfic



Christophe


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 12:14 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Ah, sorry I didn't get it before. that's right. There is some semantics in HQL. You could do this in regular sql though. And tell me again why you need to handle your associations like this. There might be other ways around it.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 29, 2008 3:34 am 
Newbie

Joined: Fri Dec 07, 2007 9:25 am
Posts: 5
Hi Farzad,

I am also facing the same issue with the same situation,not using any association between the tables.

Reason:
We dont want to give the strict mapping between the table, because we are in product environment. The relation may change based on the clients requirement.

And I already opened a new topic for the same issue
(http://forum.hibernate.org/viewtopic.ph ... outer+join)

Any guidance for this will be very helpful

Thanks,
Raji.T


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