-->
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: Mapping complicated references in NHibernate
PostPosted: Mon Jun 15, 2009 4:19 pm 
Newbie

Joined: Sun Aug 03, 2008 10:32 pm
Posts: 4
I have posted this on StackOverflow with no answers in the last day. If you would like reputation for an answer please answer it there.

I am trying to build the following association in NHibernate (the base Entity class contains an Id property, it and the attributes are from the S#arp Architecture project)

Code:
    public class Terminal : Entity {
        public virtual string Name { get; set; }
    }
    public class Order : Entity {
        [NotNull]
        public virtual Terminal Terminal { get; set; }
    }

Where the data on order is stored in ORDERS and data on terminals in stored in the TERMINALS tables. The problem is that there is no direct link between the two tables. If I had an id for ORDERS.ORDER_ID I would fetch the corresponding TERMINALS row with the following SQL.

Code:
    select t.*
    from ORDERS o
         inner join cust_prod cp on (o.CUST_PROD_ID = cp.CUST_PROD_ID)
         inner join customer_terminal ct on (cp.CUSTOMER_TERMINAL_ID = ct.CUSTOMER_TERMINAL_ID)
         inner join terminal t on (ct.TERMINAL_ID = t.TERMINAL_ID)
    where o.ORDER_ID = :p_order_id


How do I map this in NHibernate? Preferably how do I map this in Fluent NHibernate but I think I could figure it out from the XML. Also, given that the legacy database I'm working with is full of chains like this are there any best practices suggestions?


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.