-->
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.  [ 5 posts ] 
Author Message
 Post subject: Join with hibernate
PostPosted: Fri Feb 20, 2004 11:01 am 
Newbie

Joined: Fri Feb 20, 2004 10:55 am
Posts: 13
When i do this:

select m.name, dm.name
from com.MasterTable as m join com.DetailAndMaster as dm

i get this:

outer or full join must be followed by path expression

Anybody could help me? Does this work or not?

Config files:

hibernate.properties

hibernate.cglib.use_reflection_optimizer=false

hibernate.cgf.xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
<property name="connection.url">jdbc:firebirdsql://localhost/c:/StrutsHibernateExample/db/HIBERNATE.GDB</property>
<property name="connection.username">sysdba</property>
<property name="connection.password">masterkey</property>
<property name="connection.pool_size">5</property>
<property name="dbcp.maxActive">100</property>
<property name="dbcp.whenExhaustedAction">1</property>
<property name="dbcp.maxWait">120000</property>
<property name="dbcp.maxIdle">10</property>
<property name="dbcp.ps.maxActive">100</property>
<property name="dbcp.ps.whenExhaustedAction">1</property>
<property name="dbcp.ps.maxWait">120000</property>
<property name="dbcp.ps.maxIdle">10</property>
<property name="dialect">net.sf.hibernate.dialect.FirebirdDialect</property>
<property name="show_sql">true</property>
<property name="cglib.use_reflection_optimizer">false</property>
<!-- Mapping files -->
<mapping resource="com/MasterTable.hbm.xml"/>
<mapping resource="com/DetailAndMasterTable.hbm.xml"/>
<mapping resource="com/DetailTable.hbm.xml"/>
</session-factory>
</hibernate-configuration>

MasterTable.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.MasterTable" table="MASTER">
<id name="id" column="ID" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="name" column="NAME" type="java.lang.String" length="5" not-null="true"/>
<set name="detail" inverse="true" lazy="true">
<key column="ID"/>
<one-to-many class="com.MasterAndDetail"/>
</set>
</class>
</hibernate-mapping>

DetailAndMasterTable.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="DetailAndMasterTable" table="DETAIL_MASTER">
<id name="id" column="ID" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="name" column="NAME" type="java.lang.String" length="30" not-null="true"/>
<many-to-one name="master" class="com.MasterTable">
<column name="id" />
</many-to-one>
<set name="detail" lazy="true" inverse="true" cascade="delete">
<key column="ID"/>
<one-to-many class="com.DetailTable"/>
</set>
</class>
</hibernate-mapping>

DetailTable2.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.DetailTable" table="DETAIL">
<id name="id" column="ID" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="name" column="NAME" type="java.lang.String" length="5" not-null="true"/>
<many-to-one name="master" class="com.DetailAndMaster">
<column name="id" />
</many-to-one>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 11:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Just do select m.name, dm.name from com.MasterTable as m , com.DetailAndMaster as dm


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 1:08 pm 
Newbie

Joined: Fri Feb 20, 2004 10:55 am
Posts: 13
But if i do what you said the hibernate will not "renderize" then join clause in the sql generated.

It will do only:

select master1_.NAME as x0_0_ ,
masterAndDetail0_.NAME as x1_1_
from DETAIL_MASTER masterAndDetail0_,
MASTER master1_

I need the "inner join" clause in "from", or a "where" clause.

How to do the Hibernate create it to me???


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 1:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
select m.name, dm.name from com.MasterTable as m join m.detail as dm


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 1:38 pm 
Newbie

Joined: Fri Feb 20, 2004 10:55 am
Posts: 13
Yeah! Tks for the help...


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