Hallo
I got a difficult problem with a situation of a many-to-many mapping.
I have a many-to-many relationship between System and Processor, e.g. means every system can have one or many processors, and each processor can be used in one or more systems. So there are 3 tables in my database: System, Processor, and ProcessorToSystem. The table ProcessorToSystem contains 2 foreign keys (SystemId, ProcessorId) and an "Int" count.
I want to do a technical query, which returns all Systems with the specified Processor, and also get all the Processors (Fetch??).
My 3 Mapping Files:
<class name="PalaceSystem" table="System"> <id name="Id"> <generator class="guid.comb" /> </id> <set name="ProcessorList" inverse="true" lazy="true"> <key column="SystemId" /> <one-to-many class="PalaceProcessorToSystem" /> </set> </class>
<class name="PalaceProcessorToSystem" table="ProcessorToSystem"> <composite-id> <key-many-to-one name="Processor" class="PalaceProcessor" column="ProcessorId" /> <key-many-to-one name="System" class="PalaceSystem" column="SystemId" /> </composite-id> <property name="Count" not-null="true" /> </class>
<class name="PalaceProcessor" table="Processor"> <id name="Id"> <generator class="guid.comb" /> </id> <set name="SystemList" inverse="true" lazy="true"> <key column="ProcessorId"></key> <one-to-many class="PalaceProcessorToSystem"></one-to-many> </set> </class>
Can somehone help me with the query I need to do. I don't even know if i should query against PalaceSystem or against PalaceProcessorToSystem, because I want to have Properties from all 3 Entities.
|