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.  [ 1 post ] 
Author Message
 Post subject: Problem with Join between two tables.
PostPosted: Sun Feb 08, 2009 3:11 am 
Newbie

Joined: Sun May 18, 2008 11:57 pm
Posts: 4
Hello every body !
this is my Example:
Database:
Image
This is snipt code in web.config.xml:
Code:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
      <session-factory>
         <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
         <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
         <property name="connection.connection_string">
        Server=VMT;initial catalog=Northwind;user=sa;password=nothing
      </property>
      <property name="max_fetch_depth">2</property>
         <mapping assembly="QuickStart.Core"/>
      </session-factory>
</hibernate-configuration>


And folow is .cs and hbm.xml in QuickStart.Core assembly:
Cat Object:
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace QuickStart.Core.Entity
{
    [Serializable]
    public class Cat
    {         
        public Cat();     
        public virtual int Id;
        public virtual string Name;
    }

}

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    namespace="QuickStart.Core.Entity" assembly="QuickStart.Core">
  <class name="Cat" table="Cat" lazy="true">
    <id name="Id" column="Id">     
      <generator class="identity" />
    </id>
    <property name="Name" column="Name"/>             
  </class>

</hibernate-mapping>

Homes Object:
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace QuickStart.Core.Entity
{
    [Serializable]
    public class Homes
    {
        public Homes();
        public virtual int Id;
        public virtual string Home;
    }
}

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    namespace="QuickStart.Core.Entity" assembly="QuickStart.Core">

  <class name="Homes" table="Homes" lazy="true">
    <id name="Id" column="Id">
      <generator class="identity" />
    </id>
    <property name="Home" column="Home"/>   
  </class>

</hibernate-mapping>

HomeCate Object :
Code:
using System;
using System.Collections.Generic;
using System.Text;
using NHibernate.Type;
namespace QuickStart.Core.Entity
{
    [Serializable]
    public class HomeCat
    {
        public HomeCat();
        public virtual int Id;
        public virtual Cat Cat;
        public virtual Homes Home;       
        public virtual DateTime? ComesDate;     
    }
}

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    namespace="QuickStart.Core.Entity" assembly="QuickStart.Core">
  <class name="HomeCat" table="HomeCat" lazy="true">
    <id name="Id" column="Id">
      <generator class="identity" />
    </id>
    <property name="ComesDate" column="ComesDate"/>
    <many-to-one name="Cat" column="CatId" class="Cat" fetch="join" outer-join="true"/>
    <many-to-one name="Home" column="HomeId" class="Homes" fetch="join" outer-join="true"/>
  </class>
</hibernate-mapping>

CatSearch Object (this is temporary object to retriev data)
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace QuickStart.Core.Entity
{
    [Serializable]
    public class CatSearch
    {       
        public CatSearch(int id, string name, string home, DateTime? comesDate);       
        public virtual int Id;
        public virtual string Name;
        public virtual string Home;       
        public virtual DateTime? ComesDate;
    }
}

and here is my sql:
Code:
select new CatSearch(c.Id,c.Name,h.Home,hc.ComesDate) from QuickStart.Core.Entity.Cat c left join HomeCat hc left join Homes h


But exception occur:
outer or full join must be followed by path expression
Why? Can you hepl me? I realy need it. Thanks so much !!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.