Mapping Stored Procedures

852 views
Skip to first unread message

Calin

unread,
Oct 6, 2009, 3:21:48 PM10/6/09
to Fluent NHibernate
Hi,

Does Fluent support mapping store procedures ?
I've found 2 possibilities:
- http://merbla.blogspot.com/2009/02/fluent-nhibernate-with-stored.html,
mixed configuration, I don't like it very much because is not very
'fluent'
- http://maonet.wordpress.com/2009/05/06/create-your-own-parts-to-merge-stored-procedure-into-fluent-nhibernate-mappings/,
and this implementation but I am not very sure it helps.

Regards,

Paul Batum

unread,
Oct 7, 2009, 6:39:10 AM10/7/09
to fluent-n...@googlegroups.com
Yeah we don't have any support for stored procedures yet so the first link is the way to go in the meantime.

Calin

unread,
Oct 7, 2009, 8:47:20 AM10/7/09
to Fluent NHibernate
Hi Paul,

Thank you for your answer.
Are you planning to add this in the near future ?

Regards,

On Oct 7, 1:39 pm, Paul Batum <paul.ba...@gmail.com> wrote:
> Yeah we don't have any support for stored procedures yet so the first link
> is the way to go in the meantime.
>
>
>
> On Wed, Oct 7, 2009 at 6:21 AM, Calin <calinusw...@gmail.com> wrote:
>
> > Hi,
>
> >  Does Fluent support mapping store procedures ?
> >  I've found 2 possibilities:
> >  -http://merbla.blogspot.com/2009/02/fluent-nhibernate-with-stored.html,
> > mixed configuration, I don't like it very much because is not very
> > 'fluent'
> >  -
> >http://maonet.wordpress.com/2009/05/06/create-your-own-parts-to-merge...
> > ,

Hudson Akridge

unread,
Oct 7, 2009, 9:03:54 AM10/7/09
to fluent-n...@googlegroups.com
One of the ongoing goals of FNH has always been parity with NH. So yes, we're planning on adding this feature in. Along with a couple other features of NH we don't currently support.
--
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

James Gregory

unread,
Oct 7, 2009, 9:09:17 AM10/7/09
to fluent-n...@googlegroups.com
"Near future" may not be the case though. Future perhaps, near future probably not.

James Newton-King

unread,
Oct 7, 2009, 5:15:10 PM10/7/09
to Fluent NHibernate
I'd like to voice my support for this to be added. It is a shame that
we have to mix and match both approaches currently.



On Oct 8, 2:09 am, James Gregory <jagregory....@gmail.com> wrote:
> "Near future" may not be the case though. Future perhaps, near future
> probably not.
>
> On Wed, Oct 7, 2009 at 2:03 PM, Hudson Akridge <hudson.akri...@gmail.com>wrote:
>
> > One of the ongoing goals of FNH has always been parity with NH. So yes,
> > we're planning on adding this feature in. Along with a couple other features
> > of NH we don't currently support.
>

James Gregory

unread,
Oct 7, 2009, 6:21:49 PM10/7/09
to fluent-n...@googlegroups.com
Patches are welcome :)

FrankM

unread,
Nov 5, 2009, 4:51:08 PM11/5/09
to Fluent NHibernate
I have uploaded my patch here: http://podcast.overseakids.com/dotnet/sp.patch

It's based on r647. The example code will look like this:

StoredProcedurePart<T>("sql-insert", INSERT_SP).Check.None();
StoredProcedurePart<T>("sql-update", UPDATE_SP).Check.None();
StoredProcedurePart<T>("sql-delete", DELETE_SP).Check.None();


On Oct 7, 3:21 pm, James Gregory <jagregory....@gmail.com> wrote:
> Patches are welcome :)
>
> On Wed, Oct 7, 2009 at 10:15 PM, James Newton-King <
>

Rob Gibbens

unread,
Nov 5, 2009, 10:05:30 PM11/5/09
to Fluent NHibernate
I blogged about this a few days ago.

http://robgibbens.blogspot.com/2009/10/nhibernate-sql-query-with-stored.html

On Oct 6, 2:21 pm, Calin <calinusw...@gmail.com> wrote:
> Hi,
>
>  Does Fluent support mapping store procedures ?
>  I've found 2 possibilities:
>  -http://merbla.blogspot.com/2009/02/fluent-nhibernate-with-stored.html,
> mixed configuration, I don't like it very much because is not very
> 'fluent'
>  -http://maonet.wordpress.com/2009/05/06/create-your-own-parts-to-merge...,

Paul Batum

unread,
Nov 6, 2009, 7:08:42 AM11/6/09
to fluent-n...@googlegroups.com
Hi Frank,

I'm in the process of reviewing your patch, but I'm a bit of a noob when it comes to using NH with stored procedures so I'm going to have to ask what may be a dumb question...

Why do you pass the operation type as a string? From what I can tell of the NH mappings schema, the only valid values are "sql-insert", "sql-update", "sql-delete", and "sql-delete-all". If thats a case, wouldn't it be better to use an enum, such as:

StoredProcedure<T>(StoredProcedureType.SqlInsert, INSERT_SP);

or even:

SqlInsert(INSERT_SP);

My concern is that by having the user type in the string, you are requiring them to have good knowledge of HBM XML, which is something that FNH attempts to avoid!

Otherwise it looks good! Once we've got this sorted out, I'll write a couple of tests to demonstrate the fluent interface and get it into the trunk asap.

Thanks,

Paul Batum

FrankM

unread,
Nov 6, 2009, 8:39:56 AM11/6/09
to Fluent NHibernate
Thanks Paul, You are right, this is a very good improment I should
add. I'll change it to

SqlInsert(INSERT_SP);

once I back to work. then send you another patch? I just figured out
how to do generationTest for my part.

This solution doesn't cover retrieve. For reading data from SP, please
refer to Rob's way.


I know SP is bad, but some developers like me have to work on a legacy
database.

On 11月6日, 上午5时08分, Paul Batum <paul.ba...@gmail.com> wrote:
> Hi Frank,
>
> I'm in the process of reviewing your patch, but I'm a bit of a noob when it
> comes to using NH with stored procedures so I'm going to have to ask what
> may be a dumb question...
>
> Why do you pass the operation type as a string? From what I can tell of the
> NH mappings schema, the only valid values are "sql-insert", "sql-update",
> "sql-delete", and "sql-delete-all". If thats a case, wouldn't it be better
> to use an enum, such as:
>
> StoredProcedure<T>(StoredProcedureType.SqlInsert, INSERT_SP);
>
> or even:
>
> SqlInsert(INSERT_SP);
>
> My concern is that by having the user type in the string, you are requiring
> them to have good knowledge of HBM XML, which is something that FNH attempts
> to avoid!
>
> Otherwise it looks good! Once we've got this sorted out, I'll write a couple
> of tests to demonstrate the fluent interface and get it into the trunk asap.
>
> Thanks,
>
> Paul Batum
>

Wayne Douglas

unread,
Nov 6, 2009, 8:41:48 AM11/6/09
to fluent-n...@googlegroups.com
we have some pretty huge sps that would be a royal pain in the
proverbial to do any other way. sps are the only way to go for us in a
lot of cases :)
--
Cheers,

w://

Paul Batum

unread,
Nov 6, 2009, 8:27:50 PM11/6/09
to fluent-n...@googlegroups.com
I've recieved another patch from Frank and incorporated it into my branch along with some other minor changes I made. Its now available on my dev branch, and should be in the trunk in a few days.
Reply all
Reply to author
Forward
0 new messages