Sure...

Operator

<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping  auto-import="true" default-lazy="false" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="urn:nhibernate-mapping-2.2">
  <class name="Sms.Data.Domain.Operator, Sms.Data.Domain" table="operators" 
schema="dbo" lazy="true">
    <id name="Id" access="property" column="Id" type="Int32" 
unsaved-value="0">
      <generator class="native"></generator>
    </id>
    <property name="Name" access="property" type="String">
      <column name="Name"/>
    </property>
    <bag name="Clients" access="property" table="clients" lazy="false" 
inverse="true" cascade="all-delete-orphan">
      <key column="Operator" />
      <one-to-many class="Sms.Data.Domain.Client, Sms.Data.Domain" />
    </bag>
  </class>
</hibernate-mapping>


Client

<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping  auto-import="true" default-lazy="false" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="urn:nhibernate-mapping-2.2">
  <class name="Sms.Data.Domain.Client, Sms.Data.Domain" table="clients" 
schema="dbo">
    <id name="ClientId" access="property" column="Id" type="Int32" 
unsaved-value="0">
      <generator class="native"></generator>
    </id>
    <property name="AreaCode" access="property" type="String">
      <column name="AreaCode"/>
    </property>
    <property name="Cif" access="property" type="String">
      <column name="Cif"/>
    </property>
    <property name="Identification" access="property" type="String">
      <column name="Identification"/>
    </property>
    <property name="FirstName" access="property" type="String">
      <column name="FirstName"/>
    </property>
    <property name="LastName" access="property" type="String">
      <column name="LastName"/>
    </property>
    <property name="LastName2" access="property" type="String">
      <column name="LastName2"/>
    </property>
    <property name="Email" access="property" type="String">
      <column name="Email"/>
    </property>
    <property name="Notify" access="property" type="Boolean">
      <column name="Notify"/>
    </property>
    <property name="Status" access="property">
      <column name="Status"/>
    </property>
    <property name="ModifiedBy" access="property" type="String">
      <column name="ModifiedBy"/>
    </property>
    <property name="CreatedAt" access="property" type="DateTime">
      <column name="Created"/>
    </property>
    <property name="ModifiedAt" access="property" type="DateTime" 
insert="false">
      <column name="Modified"/>
    </property>
    <property name="CellPhone" access="property" type="String">
      <column name="CellPhone"/>
    </property>
    <many-to-one name="Operator" access="property" 
class="Sms.Data.Domain.Operator, Sms.Data.Domain" column="Operator" 
fetch="join" />
    <bag name="Products" access="property" table="products" lazy="true" 
inverse="true" cascade="all-delete-orphan">
      <key column="ClientId" />
      <one-to-many class="Sms.Data.Domain.Product, Sms.Data.Domain" />
    </bag>
  </class>
</hibernate-mapping>



----- Original Message ----- 
From: "Eyston" <[email protected]>
To: "nhusers" <[email protected]>
Sent: Friday, July 10, 2009 9:35 AM
Subject: [nhusers] Re: HQL Join Problem



Can you show mappings?

On Jul 10, 11:12 am, spiralni <[email protected]> wrote:
> Hi..
>
> I'd like to perform a join between two entities..
>
> [Operator] has many [Client]
>
> I can do this with this SQL sentence
>
> select c.*, o.name from clients c join operators o on c.operator =
> o.id
>
> I would like to do this same query using HQL, for this I use this HQL
> query
>
> "from Client c join fetch c.Operator where c.Status = :status and
> c.Cif in (:cifs)"
>
> The HQL query results in
>
> select (fields names goes here)
> from dbo.clients client0_ inner join dbo.operators operator1_ on
> client0_.Operator = operator1_.Id
> where (client0_.Status = 1) and (client0_.Cif in (12345670 ,
> 12345678 ))
>
> which is ok, but also execute a new query for every operator id that I
> have (in my case I have 2 operators)
>
> SELECT (fields names goes here)
> FROM dbo.clients clients0_
> WHERE clients0_.Operator = 2
>
> SELECT (fields names goes here)
> FROM dbo.clients clients0_
> WHERE clients0_.Operator = 1
>
> Which is not desirable... Why is this happening..? I just want to
> execute the first query..
>
> Hope you can help me..
>
> Thanx


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to