-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NHibernate Many-To-Many Criteria Query
PostPosted: Thu Mar 15, 2012 8:06 am 
Newbie

Joined: Thu Mar 15, 2012 7:39 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.