-->
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: ADOException caused by duplicate column aliases (SQL CE)
PostPosted: Mon Jul 20, 2009 11:50 am 
Newbie

Joined: Mon Jul 06, 2009 11:43 am
Posts: 1
Hi,

I am new to NHibernate so pls bear with me......

I'm trying to resolve a problem whereby the SQL query generated by NHibernate has a duplicate column alias which SQL CE clearly doesn't like.
This problem does not occur when querying an SQL 2005 database.

Having compared my mapping files and classes to other examples I can't see why this is happening and would appreciate it if someone could help me out.

Classes are:

ClientReport which inherits from Report
ClientPublication which inherits from Publication

A ClientReport may have one or more ClientPublications
A ClientPublication must belong to a ClientReport

ClientReport mapping:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
  <class name="ReportDistribution.Client.ReportMgr.Model.ClientReport, ReportDistribution.Client.ReportMgr.Model" table="ClientReport" lazy="false">
    <id name="Id" access="property" column="ReportID">
      <generator class="native"></generator>
    </id>
    <property name="MaxAge" access="property" />
    <property name="DeleteUnread" access="property" />
    <property name="Description" access="property" />
    <property name="Name" access="property" />
    <bag name="ClientPublications" cascade="all" lazy="false">
      <key column="ReportID"></key>
      <one-to-many
        class="ReportDistribution.Client.ReportMgr.Model.ClientPublication, ReportDistribution.Client.ReportMgr.Model" />       
    </bag>
  </class> 
</hibernate-mapping>


ClientPublication mapping:

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true">
<class name="ReportDistribution.Client.ReportMgr.Model.ClientPublication, ReportDistribution.Client.ReportMgr.Model" table="ClientPublication" lazy="false" >
  <id name="Id" access="property" column="PublicationID">
    <generator class="native"></generator>
  </id> 
  <property name="ReportId" access="property"></property>
  <property name="CreatedOn" access="property"></property>
  <property name="IsMarkedForDeletion" access="property"></property>
  <property name="IsDeleted" access="property"></property>
  <property name="HasBeenRead" access="property"></property>
  <property name="ReceivedOn" access="property"></property>
  <property name="FileExtension" access="property"></property>
  <property name="IsConverted" access="property"></property>
  <property name="IsDownloaded" access="property"></property>
  <many-to-one 
    name="ClientReport"
    class="ReportDistribution.Client.ReportMgr.Model.ClientReport, ReportDistribution.Client.ReportMgr.Model"
    column="ReportID" lazy="false"
    not-null="true">
  </many-to-one>
</class>
</hibernate-mapping>


The SQL generate by NHibernate is:

Code:
[SQL: SELECT clientpubl0_.ReportID as ReportID__1_, clientpubl0_.PublicationID as Publicat1_1_, clientpubl0_.PublicationID as Publicat1_0_0_, clientpubl0_.ReportId as ReportId0_0_, clientpubl0_.CreatedOn as CreatedOn0_0_, clientpubl0_.IsMarkedForDeletion as IsMarked4_0_0_, clientpubl0_.IsDeleted as IsDeleted0_0_, clientpubl0_.HasBeenRead as HasBeenR6_0_0_, clientpubl0_.ReceivedOn as ReceivedOn0_0_, clientpubl0_.FileExtension as FileExte8_0_0_, clientpubl0_.IsConverted as IsConver9_0_0_, clientpubl0_.IsDownloaded as IsDownl10_0_0_, clientpubl0_.ReportID as ReportID0_0_ FROM ClientPublication clientpubl0_ WHERE clientpubl0_.ReportID=?]


The duplicated column alias is "ReportId0_0_"

Thanks.


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.