nhibernate-core icon indicating copy to clipboard operation
nhibernate-core copied to clipboard

NH-3187 - Ability to filter a bag with where in mapping by inherited columns

Open nhibernate-bot opened this issue 7 years ago • 1 comments

Alexander Zaytsev created an issue — :

  <class name="Person">
    <id name="Id" generator="guid.comb" />
    <property name="Name"/>
    <property name="IsDeleted"/>
    <joined-subclass name="Policeman">
      <key column="PersonId" />
      <many-to-one name="Station" column="StationId" />
    </joined-subclass>
  </class>

  <class name="Station">
    <id name="Id" generator="guid.comb" />
    <bag name="Policemen" where="IsDeleted = 0">
      <key column="StationId" />
      <one-to-many class="Policeman"/>
    </bag>
  </class>

Accessing to station.Policemen generates wrong sql:


    SELECT
        policemen0_.StationId as StationId1_,
        policemen0_.PersonId as PersonId1_,
        policemen0_.PersonId as Id0_0_,
        policemen0_1_.Name as Name0_0_,
        policemen0_1_.IsDeleted as IsDeleted0_0_,
        policemen0_.StationId as StationId1_0_ 
    FROM
        Policeman policemen0_ 
    inner join
        Person policemen0_1_
            on policemen0_.PersonId=policemen0_1_.Id 
    WHERE
        (
            policemen0_.IsDeleted = 0 -- should be policemen0_1_
        ) 
        and policemen0_.StationId=@p0;

Alexander Zaytsev added a comment — :

Test commited

nhibernate-bot avatar Oct 12 '17 12:10 nhibernate-bot

I am having this same issue. Looking forward to a fix!

jehhynes avatar May 23 '23 13:05 jehhynes