views:

110

answers:

1

I have two tables that are considered a single entity in my domain model.

I join them in my IAutoMappingOverride by calling IgnoreProperty on the properties of the joined table and then using Join with a Map for each of the properties.

This configuration works, but I'm lost at attempting a filter on the columns of the joined table. If I call the following:

Session.CreateCriteria<PrimaryEntity>()
    .CreateCriteria("ExtraPropertiesTable", JoinType.InnerJoin)
    .Add(Expression.Eq("Language", language)) // Column on ExtraPropertiesTable
    .List(primaryEntitiesList);

I get the following exception:

QueryException: could not resolve property: ExtraPropertiesTable of: PrimaryEntity

I have also tried DetachedCriteria to no avail.

Any ideas?

+1  A: 

If both tables are mapped to the same entity, you shouldn't have to do a join in the hibernate query, you should only refer to the entity, and hibernate will generate the join in the SQL query it generates. Also, the CreateCriteria method expect the name of a mapped entity, not a table.

Guillaume Poirier
This is correct. The problem was in my fluent configuration: I had used an auto-configuration override and IgnorePropety the joined properties (since they were already configured automatically). The fix was to use a full ClassMap<>, in which the IgnoreProperty calls were not necessary. After all this, a simple property reference was sufficient to filter the property.
Richard Szalay