We have some tests with similar situation without problems. 2010/2/2 Kirtan Loor <[email protected]>
> Hi, > > I have a question, concerning mapping table references in nhibernate. > My (MySQL) database tables looks like that: > > CREATE TABLE `games` ( > `game_id` int(10) unsigned NOT NULL AUTO_INCREMENT, > `played_time` int(10) unsigned NOT NULL, > `dealings` int(10) unsigned NOT NULL, > `player_1` int(10) unsigned NOT NULL, > `player_2` int(10) unsigned NOT NULL, > `player_3` int(10) unsigned NOT NULL, > `player_4` int(10) unsigned NOT NULL, > PRIMARY KEY (`game_id`), > KEY `player_1` (`player_1`), > KEY `player_2` (`player_2`), > KEY `player_3` (`player_3`), > KEY `player_4` (`player_4`), > KEY `dealings` (`dealings`), > CONSTRAINT `player_1` FOREIGN KEY (`player_1`) REFERENCES `players` > (`player_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, > CONSTRAINT `player_2` FOREIGN KEY (`player_2`) REFERENCES `players` > (`player_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, > CONSTRAINT `player_3` FOREIGN KEY (`player_3`) REFERENCES `players` > (`player_id`) ON DELETE NO ACTION ON UPDATE NO ACTION, > CONSTRAINT `player_4` FOREIGN KEY (`player_4`) REFERENCES `players` > (`player_id`) ON DELETE NO ACTION ON UPDATE NO ACTION > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > DROP TABLE IF EXISTS `players`; > CREATE TABLE `players` ( > `player_id` int(10) unsigned NOT NULL AUTO_INCREMENT, > `username` varchar(75) NOT NULL, > `password` char(32) NOT NULL, > `player_joined` int(10) unsigned NOT NULL, > `player_name` varchar(75) DEFAULT NULL, > `player_surname` varchar(100) DEFAULT NULL, > PRIMARY KEY (`player_id`), > KEY `username` (`username`), > KEY `joined` (`player_joined`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; > > As you can see, I have 4 references in table games to table users > (we're creating a Contract Bridge site). I want to know, how to map > this in nhibernate. I used: > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > assembly="Website" namespace="Website.Database.Model"> > <class name="Website.Database.Model.Games, Website" table="games"> > <id name="GameId" column="game_id" type="int"> > <generator class="native" /> > </id> > <property name="PlayedTime" column="played_time" > type="int"/> > <property name="Dealings" column="dealings" type="int"/> > > <many-to-one name="Player1" fetch="select" index="player_1" > class="Players" column="player_1" foreign-key="player_1" /> > <many-to-one name="Player2" fetch="select" index="player_1" > class="Players" column="player_2" foreign-key="player_2" /> > <many-to-one name="Player3" fetch="select" index="player_1" > class="Players" column="player_3" foreign-key="player_3" /> > <many-to-one name="Player4" fetch="select" index="player_1" > class="Players" column="player_4" foreign-key="player_4" /> > </class> > </hibernate-mapping> > > but, all in all, it returns only player 4 for all players. Is it > possible to do such thing in nhibernate without using collections? I > am new in nhibernate, so any tips would be very helpfull :) > > salute, > Maciej Krasuski > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- Fabio Maulo -- 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.
