Hibernate version:1.0.2
Hi,
I am working on a project that uses nhibernate as the OR mapper. In the context of some prototyping of search facilities in our application, I was looking into the NHibernate.Mapping namespace classes, to see how we can use the metadata model of NHibernate to configure search options in our searches (in particular, the properties of objects that the user can search on ...).
The search functionality should be quite advanced, and the configuration of a search on a particular type of object should allow for the filtering on properties of associated objects (say something like "give me the persons on our system that drive a BMW and have a blank accident record").
So I was writing some simple tests to see if I would be able to retrieve enough information to use it in that kind of configurations.
This is where I've gotten this far: starting from the Configuration, I can run over the ClassMappings collection. For each of these mappings, I can run over the properties, and display some info about them.
The latter action runs fine for value type properties. For associations, it depends on the type of association:
A one to one association can be detected using Code:
Property.Type.IsAssociationType
together with Code:
Property.Type.IsEntityType
A one to many association can be detected using Code:
((Bag)Property.Value).IsOneToMany
However, I can't find in the object model how I have to discover the concrete type of objects stored in the collection property representing a many to many association. I'm probably looking over it, but I didn't find a way to do this until now.
A similar problem goes for the association mapped as a bag of composite elements. Also in this case, I find the property representing the association in the meta model, but I am not able to determine the actual type stored in the bag.
Some help on this would be much appreciated ...