All,

I have the following mapping files:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping
    xmlns="urn:nhibernate-mapping-2.2"
    namespace="Sample.Domain"
    assembly="Sample.Domain"
    default-access="field.camelcase-underscore"
    default-lazy="true">
  <class name="User"
         proxy="Sample.Domain.Interfaces.IUser,
Sample.Domain.Interfaces"
         table="[User]">
    <id name="Id" column="Id" unsaved-
value="00000000-0000-0000-0000-000000000000" access="property">
      <generator class="guid.comb" />
    </id>
    <version name="Version" column="Version" type="binary" unsaved-
value="null" generated="always"/>
    <property name="Active" type="boolean" not-null="true" />
    <property name="Name" type="string" length="50" not-null="true" />

    <bag name="Groups" table="UserGroup" inverse="true"
cascade="delete" optimistic-lock="false" >
      <key column="UserId" />
      <many-to-many class="Group" />
    </bag>

    <!-- Class is made up of two tables but the Audit table is
optional for a User -->
    <join table="Audit" optional="true">
      <key column="EntityId" />
      <property name="CreatedBy" />
      <property name="CreatedTimestamp" />
      <property name="UpdatedBy" />
      <property name="UpdatedTimestamp" />
    </join>
  </class>
</hibernate-mapping>

and

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping
    xmlns="urn:nhibernate-mapping-2.2"
    namespace="Sample.Domain"
    assembly="Sample.Domain"
    default-access="field.camelcase-underscore"
    default-lazy="true">
  <class name="Group"
         proxy="Sample.Domain.Interfaces.IGroup,
Sample.Domain.Interfaces"
         table="[Group]">
    <id name="Id" column="Id" unsaved-
value="00000000-0000-0000-0000-000000000000" access="property">
      <generator class="guid.comb" />
    </id>
    <version name="Version" column="Version" type="binary" unsaved-
value="null" generated="always"/>
    <property name="Name" type="string" length="50" not-null="true" />

    <bag name="Users" table="UserGroup" inverse="true"
cascade="delete" optimistic-lock="false" >
      <key column="GroupId" />
      <many-to-many class="User" />
    </bag>

    <bag name="Permissions" table="TaskGroup" inverse="true"
cascade="delete" optimistic-lock="false" >
      <key column="GroupId" />
      <many-to-many class="Task" />
    </bag>

    <!-- Class is made up of two tables but the Audit table is NOT
optional for a group -->
    <join table="Audit">
      <key column="EntityId" />
      <property name="CreatedBy" />
      <property name="CreatedTimestamp" />
      <property name="UpdatedBy" />
      <property name="UpdatedTimestamp" />
    </join>
  </class>
</hibernate-mapping>

and

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping
    xmlns="urn:nhibernate-mapping-2.2"
    namespace="Sample.Domain"
    assembly="Sample.Domain"
    default-access="field.camelcase-underscore"
    default-lazy="true">
  <class name="Task"
         proxy="Sample.Domain.Interfaces.ITask,
Sample.Domain.Interfaces"
         table="Task">
    <id name="Id" column="Id" unsaved-
value="00000000-0000-0000-0000-000000000000" access="property">
      <generator class="guid.comb" />
    </id>
    <version name="Version" column="Version" type="binary" unsaved-
value="null" generated="always"/>
    <property name="Lookup" type="string" length="50" not-null="true" /
>
    <property name="Description" type="string" length="255" not-
null="true" />

    <!-- Class is made up of two tables but the Audit table is
optional for a Task -->
    <join table="Audit" optional="true">
      <key column="EntityId" />
      <property name="CreatedBy" />
      <property name="CreatedTimestamp" />
      <property name="UpdatedBy" />
      <property name="UpdatedTimestamp" />
    </join>
  </class>
</hibernate-mapping>

When I perform the following HQL query:

SELECT u FROM User AS u INNER JOIN u.Groups as g INNER JOIN
g.Permissions AS p WHERE p.Id = :taskId AND u.Id = :userId

to navigate the object model the SQL generated is:

select user0_.Id as Id0_, user0_.Version as Version0_, user0_.Active
as Active0_, user0_.Name as Name0_, user0_1_.CreatedBy as CreatedBy2_,
user0_1_.CreatedTimestamp as CreatedT3_2_, user0_1_.UpdatedBy as
UpdatedBy2_, user0_1_.UpdatedTimestamp as UpdatedT5_2_
from [User] user0_ left outer join Audit user0_1_ on
user0_.Id=user0_1_.EntityId
inner join UserGroup groups1_ on user0_.Id=groups1_.UserId
inner join [Group] group2_ on groups1_.elt=group2_.Id
inner join Audit group2_1_ on group2_.Id=group2_1_.EntityId
inner join TaskGroup permission3_ on group2_.Id=permission3_.GroupId
inner join Task task4_ on permission3_.elt=task4_.Id
left outer join Audit task4_1_ on task4_.Id=task4_1_.EntityId


This fails because NHibernate has created an unknown column "elt" to
match against the Permission collection (Task mapping) and the same
for the Groups mapping. Where on earth has this come from? Is there a
mistake in my many-to-many mappings?

Thanks

--~--~---------~--~----~------------~-------~--~----~
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