Hello there - can anyone tell me if its possible to use the criteria
API and NHibernate 2.0 to search against the contents of a bag of
composite-element instances?
My attempts so far have all failed.
My table/class setup is as follows:
A -* M *- B
The "A" and "B" are entities meaning that they both have a primary key
in NHibernate. "A" has a bag of "M"s.
The "M" class is currently mapped as a composite-element. The reason
for this is that the table "M" has a composite primary key with two
columns pointing to "A" and "B" plus extra information for the
association. It has proved difficult to map the "M" class as an
entity.
Instead it is mapped as follows in the mapping for "A":
<bag name="MList" >
<key column="AId" />
<composite-element class="M">
<property ... />
<property ... />
<many-to-one name="B" column="BId" class="B" />
</composite-element>
</bag>
Now, I want to retrieve instances of "A" based on the contents of its
"MList" property.
Creating a DetachedCriteria for "M" results in a null exception, which
I believe is due to the fact that "M" is not an entity.
Creating an alias for the "MList" on "A" results in an exception
saying "Collection is not an association".
My currently planned workaround is to add an identity column to "M"
and upgrade it to an entity, but if I can avoid doing that it would be
nice.
Any suggestions?`
Regards
Thomas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---