Hi,
Ihave a bug when send the sql request to nhibernate with the :
IQuery q = m_session.CreateSQLQuery(request);
result = q.SetTimeout(3600).List();
The bug is that I want to see the c.Dv field et the c.Dn values but I see 2 times the same value of the field c.Dv in the result list .The two fields are decimal(18,3).
I would write the sql query in Hql. Can Someones can help me please ?Code:
SELECT o.OutletId, o.Name, (SELECT DISTINCT c.Dv From CoeficientProd c WHERE c.OutletId = o.OutletId AND c.DayId=20091105),
(SELECT DISTINCT c.Dn From CoeficientProd c WHERE c.OutletId = o.OutletId AND c.DayId=20091105) From Outlet o, OutletSubChannel osc
WHERE o.OutletId=osc.OutletId AND osc.SubChannelId IN (9,236,5,233,6,234,2,1,10,8,237,7,4,238,239,0,235,3,11)
ORDER BY o.OutletId
Theses are my nhibernate classes :
Code:
public class Outlet
{
private int m_Id;
private String m_Name;
private String m_Code;
private Boolean m_IsDummy;
private OutletGroup m_OutletGroup;
private IList<SubChannel> m_SubChannels;
private IList<Bkz> m_BKZs;
private String m_adress;
private String m_postalCode;
private String m_country;
private Department m_Department;
private int m_Size;
}
public class SubChannel
{
private int m_Id;
private String m_Name;
private Channel m_Channel;
private IList<Outlet> m_Outlets;
}
public class CoeficientProd
{
private int m_Id;
private Outlet m_Outlet;
private Day m_Day;
private LoadProcess m_LoadProcess;
private Double m_DN;
private Double m_DV;
private String m_TypeDndv;
}
and my hbm
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="CoeficientProd" table="CoeficientProd">
<!--<cache usage="read-write"/>-->
<id name="Id" column="CoeficientId" unsaved-value="0">
<generator class="native"/>
</id>
<many-to-one name="Outlet" column="OutletId" not-null="false"/>
<many-to-one name="Day" column="DayId" not-null="false"/>
<many-to-one name="LoadProcess" column="LoadProcessId" not-null="false"/>
<!--<property name="DN" column="DN" type="decimal(18,3)" not-null="false"/>
<property name="DV" column="DV" type="decimal(18,3)" not-null="false"/>-->
<property name="DN" column="DN" not-null="false"/>
<property name="DV" column="DV" not-null="false"/>
<property name="TypeDndv" column="TypeDndv" not-null="false"/>
<property name="LastModified" column="lastModified" not-null="false" />
<property name="LastModifiedBy" column="lastModifiedBy" not-null="false" />
<property name="CreateDate" column="createDate" not-null="false" />
<property name="CreatedBy" column="createdBy" not-null="false" />
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Outlet" table="Outlet">
<id name="Id" column="OutletId" unsaved-value="0">
<generator class="native"/>
</id>
<property name="Name" column="Name" not-null="false"/>
<property name="Code" column="Code" not-null="false" length="6"/>
<property name="IsDummy" column="IsDummy" not-null="false"/>
<bag
name="BKZs"
inverse="true"
lazy="true"
cascade="save-update">
<key column="OutletId"/>
<one-to-many class="GFK.CEB.Business.Bkz"/>
</bag>
<property name="Adress" column="Adress" not-null="false"/>
<property name="PostalCode" column="PostalCode" not-null="false"/>
<property name="Country" column="Country" not-null="false"/>
<many-to-one name="OutletGroup" column="OutletGroupId" not-null="false"/>
<many-to-one name="Department" column="DepartmentId" not-null="false" />
<bag name="SubChannels" table="OutletSubChannel" inverse="true" lazy="true"
cascade="save-update">
<key column="OutletId"/>
<many-to-many column="SubChannelId"
class="SubChannel"/>
</bag>
<property name="Size" column="Size" not-null="false"/>
<property name="LastModified" column="lastModified" not-null="false" />
<property name="LastModifiedBy" column="lastModifiedBy" not-null="false" />
<property name="CreateDate" column="createDate" not-null="false" />
<property name="CreatedBy" column="createdBy" not-null="false" />
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="SubChannel" table="SubChannel">
<id name="Id" column="SubChannelId" unsaved-value="0">
<generator class="native"/>
</id>
<property name="Name" column="Name" not-null="false"/>
<many-to-one name="Channel" column="ChannelId" not-null="false"/>
<bag name="Outlets" table="OutletSubChannel" cascade="none" lazy="true" >
<key column="SubChannelId"/>
<many-to-many column="OutletId"
class="Outlet"/>
</bag>
<property name="LastModified" column="lastModified" not-null="false" />
<property name="LastModifiedBy" column="lastModifiedBy" not-null="false" />
<property name="CreateDate" column="createDate" not-null="false" />
<property name="CreatedBy" column="createdBy" not-null="false" />
</class>
</hibernate-mapping>