Hello every body !
this is my Example:
Database:
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 !!!