References object by two columns ?

846 views
Skip to first unread message

Gregory Kaidanov

unread,
Jan 24, 2010, 10:10:02 AM1/24/10
to Fluent NHibernate, ste...@rnbsolutions.net, Olga.Kr...@ness.com
Hello there !
I have trouble referencing some object to my entity by two conditions
in the join .

So if i have this sql -
select * from t1 left join t2
on t1.col1 = t2.col1
and t1.col2 = t2.col2

It's getting me a HasOne relationship - it's a unique answer for each
record from t1 .

So , in mapping of the t1 entity , i'm mapping it in this manner -

References(x => x.t2Object).Colummns("Col1", "Col2").PropertyRef(d
=> d.Col1).PropertyRef(d => d.Col2).Fetch.Join();
as I understand it , I've givven the FNH the columns that I want to
reffer to , and reference mapping by order of the join .

Is there any way to do it?

I'm working with FNH # 164 .

Hudson Akridge

unread,
Jan 24, 2010, 10:21:03 AM1/24/10
to fluent-n...@googlegroups.com
I don't believe you can propertyref on more than one column. This is an NH limitation, as you'd need to define a <properties> tag for your propertyref, which I don't believe you can do in NH yet (That's something available in Hibernate though). So what you're going to have to do is join on your first column's property ref, and then add a .Where() constraint for your second property.


--
You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group.
To post to this group, send email to fluent-n...@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.




--
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

Gregory Kaidanov

unread,
Jan 24, 2010, 10:38:28 AM1/24/10
to Fluent NHibernate
But there is no where on the References .
Can you provide some syntax for example?

On Jan 24, 5:21 pm, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> I don't believe you can propertyref on more than one column. This is an NH
> limitation, as you'd need to define a <properties> tag for your propertyref,
> which I don't believe you can do in NH yet (That's something available in
> Hibernate though). So what you're going to have to do is join on your first
> column's property ref, and then add a .Where() constraint for your second
> property.
>

> On Sun, Jan 24, 2010 at 9:10 AM, Gregory Kaidanov <2bher...@gmail.com>wrote:
>
>
>
>
>
> > Hello there !
> > I have trouble referencing some object to my entity by two conditions
> > in the join .
>
> > So if i have this sql -
> > select * from t1 left join t2
> > on t1.col1 = t2.col1
> > and t1.col2 = t2.col2
>
> > It's getting me a HasOne relationship - it's a unique answer for each
> > record from t1 .
>
> > So , in mapping of the t1 entity , i'm mapping it in this manner -
>
> >   References(x => x.t2Object).Colummns("Col1", "Col2").PropertyRef(d
> > => d.Col1).PropertyRef(d => d.Col2).Fetch.Join();
> > as I understand it , I've givven the FNH the columns that I want to
> > reffer to , and reference mapping by order of the join .
>
> > Is there any way to do it?
>
> > I'm working with FNH  # 164 .
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Fluent NHibernate" group.
> > To post to this group, send email to fluent-n...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr i...@googlegroups.com>

Reply all
Reply to author
Forward
0 new messages