nHibernate Configuration Fluent Interface

7 views
Skip to first unread message

Andy

unread,
Jul 23, 2008, 10:15:25 AM7/23/08
to nhusers
Hi

I've been experimenting this morning and at the moment I've got the
below syntax working:

public class DeveloperMapping : NHibernateMap<Developer>
{
public override void Map()
{
Table("Developer")
.Identity(d => d.DeveloperId)
.Property("Developer", d => d.Name)
.Property("IsBuilder", d => d.IsBuilder);
}
}

Now this looks extremely similar to Jeremy Millers dsl except I
probably have alot less functionality:

http://codebetter.com/blogs/jeremy.miller/archive/2008/06/18/working-faster-and-fewer-mapping-errors-with-nhibernate.aspx

I was just wondering if anyone is interested in this and would it be
of value to create a os project to do a more complete implemntation,
as far as I know mr millers isnt open source it's part of his story
teller solution and I couldn't find any others.

Cheers

Andy

James Gregory

unread,
Jul 23, 2008, 10:41:27 AM7/23/08
to nhu...@googlegroups.com
Is this not Jeremey's: http://storyteller.tigris.org/svn/storyteller/trunk/src/ShadeTree.DomainModel/Mapping/

Username is guest, password is blank/nothing.

Simone Busoli

unread,
Jul 23, 2008, 10:39:49 AM7/23/08
to nhu...@googlegroups.com
It should be an os project, you might ask him if he is willing to accept contributions.

Andy

unread,
Jul 23, 2008, 10:48:54 AM7/23/08
to nhusers
Thats the one, it's just not an actual open source project.

Andy

On Jul 23, 3:41 pm, "James Gregory" <jagregory....@gmail.com> wrote:
> Is this not Jeremey's:http://storyteller.tigris.org/svn/storyteller/trunk/src/ShadeTree.Dom...
>
> Username is guest, password is blank/nothing.
>
> On Wed, Jul 23, 2008 at 3:15 PM, Andy <AndrewNStew...@gmail.com> wrote:
>
> > Hi
>
> > I've been experimenting this morning and at the moment I've got the
> > below syntax working:
>
> >    public class DeveloperMapping : NHibernateMap<Developer>
> >    {
> >        public override void Map()
> >        {
> >            Table("Developer")
> >                .Identity(d => d.DeveloperId)
> >                .Property("Developer", d => d.Name)
> >                .Property("IsBuilder", d => d.IsBuilder);
> >        }
> >    }
>
> > Now this looks extremely similar to Jeremy Millers dsl except I
> > probably have alot less functionality:
>
> >http://codebetter.com/blogs/jeremy.miller/archive/2008/06/18/working-...

James Gregory

unread,
Jul 23, 2008, 10:57:02 AM7/23/08
to nhu...@googlegroups.com
Ah, I didn't realise that. Apologies.

Andy

unread,
Jul 23, 2008, 11:00:14 AM7/23/08
to nhusers
Not a problem, I've sent Jeremy an email to see if thats an option or
not and if he would accept patches.

Cheers

Andy

On Jul 23, 3:57 pm, "James Gregory" <jagregory....@gmail.com> wrote:
> Ah, I didn't realise that. Apologies.
>

Jeremy Miller

unread,
Jul 23, 2008, 11:23:21 AM7/23/08
to nhusers
Guys,

I would *love* to have some volunteers to help make it a "real" open
source project. It's a bit rough at the moment and the test coverage
is frankly not very good. Unsurprisingly, it's a little bit coupled
to StructureMap, but I'm happy to remove that. We are dogfooding it
in our current project with no real difficulties. Honestly, I'd even
like to see someone not named "Jeremy" just flat out take it over.

We also have:

* some pluggable conventions for Primary Key naming, FK naming, "if
the property is this type, then use this custom IUserType for
mapping," "override the mappings like this anytime it's this property"
* pluggable directives for "if you see this attribute, do this other
stuff to the mappings" For example, if a property is marked with our
[Required] validation attribute, our mapping will make the field non-
null for the hbm2ddl tool
* A generic repository that uses Linq for NHibernate.
* The beginnings of a query engine to translate from DTO's sent up
from the client into Linq Expressions
* some test data infrastructure that plugs into this stuff for setting
up domain entities in Fit tests. I might be the only person that
cares about that though
* a declarative tool for testing NHibernate mappings

Anyway, let me know if you're interested.

Jeremy

James Gregory

unread,
Jul 23, 2008, 11:37:46 AM7/23/08
to nhu...@googlegroups.com
Sounds like we're onto a winner. I'll raise my hand for helping out, as this is something I'm seriously interested in.

Victor Kornov

unread,
Jul 23, 2008, 12:34:35 PM7/23/08
to nhu...@googlegroups.com
Jeremy, would you be so kind to elaborate more on "* The beginnings of a query engine to translate from DTO's sent up
from the client into Linq Expressions"? Sounds interesting, I'm just not sure what's the use case and how you use it.

Jeremy Miller

unread,
Jul 23, 2008, 1:57:55 PM7/23/08
to nhusers
Sure. Let's say you've got the classic query screen going on the
client, and in our case it's a javascript widget. The user makes some
selections and you send to the server a message that looks like:

Query Message
----------------------
entity name ("address" or "site" or "contact" for us)

and an array of little dto objects like:

Filter
-------
property (Address1 or City or PostalCode for our Address query screen)
operator ('EQUAL' or 'LESSTHAN' or ...)
value

We take that query DTO, figure out what Entity you're looking for,
create a Linq Expression to match, and return the list of results
returned from the Repository for that query

Tuna Toksöz

unread,
Jul 23, 2008, 2:04:43 PM7/23/08
to nhu...@googlegroups.com
Is it something like linq provider for nhibernate?
--
Tuna Toksöz

Typos included to enhance the reader's attention ...

James Gregory

unread,
Jul 23, 2008, 2:32:10 PM7/23/08
to nhu...@googlegroups.com
Well it seems there's an interest in getting a project going for this, anyone have any thoughts on the way forward?

Jeremy, do you have some kind of issues list that people could pick at? I've got a free weekend coming up (hallelujah!), so I'll have a dig into the code and see what I can make of it; I might filling out the tests some more if I can.

Heinrich Breedt

unread,
Jul 23, 2008, 6:32:16 PM7/23/08
to nhu...@googlegroups.com
Putting my hand up as well. Being a newbie as far as helping out with an OS project, I would appreciate some pointers of how to get involved with this.

sbohlen

unread,
Jul 24, 2008, 6:56:04 AM7/24/08
to nhusers
I would love to contribute to this as well if there is interest in one
more contributor; I think that adding this to the already-existing
universe of choices about how to create nhib mappings (other choices
include hand-tuning, code-gen, etc.) would help A LOT. I'm uncertain
that this is an appropriate answer for EVERY case, but I can certainly
see how it would be useful in at least a good number of cases.

Thought: should something like this somehow be folded into the larger
universe of nhib contrib vs. being a completely sep OSS project --?
Not trying to over-complicate, but also thinking that having it part
of the formally-acknowledged nhib contrib effort would lead to its
wider 'discoverability' by more people.

-Steve B.

On Jul 23, 6:32 pm, "Heinrich Breedt" <heinrichbre...@gmail.com>
wrote:
> Putting my hand up as well. Being a newbie as far as helping out with an OS
> project, I would appreciate some pointers of how to get involved with this.
>
> On Thu, Jul 24, 2008 at 4:32 AM, James Gregory <jagregory....@gmail.com>
> wrote:
>
>
>
> > Well it seems there's an interest in getting a project going for this,
> > anyone have any thoughts on the way forward?
> > Jeremy, do you have some kind of issues list that people could pick
> > at? I've got a free weekend coming up (hallelujah!), so I'll have a dig into
> > the code and see what I can make of it; I might filling out the tests some
> > more if I can.
>
> > On Wed, Jul 23, 2008 at 7:04 PM, Tuna Toksöz <tehl...@gmail.com> wrote:
>
> >> Is it something like linq provider for nhibernate?
> >>  Wed, Jul 23, 2008 at 8:57 PM, Jeremy Miller <jeremydmil...@yahoo.com>
> >> Typos included to enhance the reader's attention ...- Hide quoted text -
>
> - Show quoted text -

James Gregory

unread,
Jul 24, 2008, 7:09:34 AM7/24/08
to nhu...@googlegroups.com
Welcome, the more the merrier! :)

We're just in discussions over where it'll be hosted. Once we know more, then I'll post here and we can get started.

Brett Veenstra

unread,
Jul 24, 2008, 6:47:11 AM7/24/08
to nhusers
I'm also interested in helping out as a newbie to an OSS project.

Are you going to put it in a dedicated project on CollabNet,
SourceForge, Google Code?


On Jul 23, 6:32 pm, "Heinrich Breedt" <heinrichbre...@gmail.com>
wrote:
> Putting my hand up as well. Being a newbie as far as helping out with an OS
> project, I would appreciate some pointers of how to get involved with this.
>
> On Thu, Jul 24, 2008 at 4:32 AM, James Gregory <jagregory....@gmail.com>
> wrote:
>
> > Well it seems there's an interest in getting a project going for this,
> > anyone have any thoughts on the way forward?
> > Jeremy, do you have some kind of issues list that people could pick
> > at? I've got a free weekend coming up (hallelujah!), so I'll have a dig into
> > the code and see what I can make of it; I might filling out the tests some
> > more if I can.
>
> > On Wed, Jul 23, 2008 at 7:04 PM, Tuna Toksöz <tehl...@gmail.com> wrote:
>
> >> Is it something like linq provider for nhibernate?
> >>  Wed, Jul 23, 2008 at 8:57 PM, Jeremy Miller <jeremydmil...@yahoo.com>

Tuna Toksöz

unread,
Jul 24, 2008, 7:22:09 AM7/24/08
to nhu...@googlegroups.com
or maybe assembla?

Ken Egozi

unread,
Jul 24, 2008, 7:27:07 AM7/24/08
to nhu...@googlegroups.com

James Gregory

unread,
Jul 24, 2008, 7:45:51 AM7/24/08
to nhu...@googlegroups.com
Looks interesting!

James Gregory

unread,
Jul 24, 2008, 7:53:27 AM7/24/08
to nhu...@googlegroups.com
I do like github, but it doesn't really do much for projects, no tickets, and no concept of "projects" (ie. the central repository has to be associated with a user). It focuses more on just being source control host.

Shame really, because it is rather awesome.

Ken Egozi

unread,
Jul 24, 2008, 7:56:19 AM7/24/08
to nhu...@googlegroups.com
you do have a wiki.
anyway, it specialises in one thing, and do it well.
but it integrates with various external ticket/issue services for project management - again - specialising projects.
I find the github/lighthouse integration very useful.

Simone Busoli

unread,
Jul 24, 2008, 7:23:00 AM7/24/08
to nhu...@googlegroups.com
Assembla is cool.

Fabio Maulo

unread,
Jul 24, 2008, 8:58:49 AM7/24/08
to nhu...@googlegroups.com
NH.Contrib ?
--
Fabio Maulo

James Gregory

unread,
Jul 24, 2008, 9:02:13 AM7/24/08
to nhu...@googlegroups.com
Eventually, I imagine. It's a little early days yet I think.

Simone Busoli

unread,
Jul 24, 2008, 7:28:12 AM7/24/08
to nhu...@googlegroups.com
Cooler

James Gregory

unread,
Jul 24, 2008, 6:34:57 PM7/24/08
to nhu...@googlegroups.com
Ok, we've ended up going with GoogleCode. It's simple, familiar, to the point, and has the smallest barrier of entry for contributors.

The project is at http://code.google.com/p/fluent-nhibernate/, although it's currently pretty sparse. I'll be dealing with getting the source up tomorrow, and we can start fleshing out the wiki and issues list as we go.

So if anyone is interested in contributing, could you drop me an e-mail with your google account address and I'll get you added as a member.

Thanks guys

Yitzchok (adminjew)

unread,
Jul 25, 2008, 11:18:57 AM7/25/08
to nhu...@googlegroups.com
It would also be nice to generate a hbm.xml file from the code.

Gabriel Schenker

unread,
Jul 29, 2008, 1:30:37 AM7/29/08
to nhu...@googlegroups.com
Just downloaded the code and browsing it. Interesting!
Note: there might be a problem with the current implementation of the base Entity class. The Hash code algorithm will return different value for a new item that has not yet been saved to db compared to after having saved it to the db! That is a problem. For a possible solution see my article on the NHibernate FAQ blog

http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/04/identity-field-equality-and-hash-code.aspx

by the way I'm interested in contributing and I'll definitely write a blog post about the topic as soon as I have some free time...

Fabio Maulo

unread,
Jul 29, 2008, 1:37:22 AM7/29/08
to nhu...@googlegroups.com
2008/7/29 Gabriel Schenker <gnsch...@gmail.com>

For a possible solution see my article on the NHibernate FAQ blog

http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/04/identity-field-equality-and-hash-code.aspx

by the way I'm interested in contributing and I'll definitely write a blog post about the topic as soon as I have some free time...

Only a note about the article:
NaturalId will be a NH2.1.0 feature.

--
Fabio Maulo

Gabriel Schenker

unread,
Jul 29, 2008, 1:47:28 AM7/29/08
to nhu...@googlegroups.com
Fabio: can you explain... What IS NaturalId and how does it work? As soon as I understand I'll update the post.

Gabriel Schenker

unread,
Jul 29, 2008, 1:51:59 AM7/29/08
to nhu...@googlegroups.com
ok. found it myself here in the Hibernate documentation (should search before ask...sorry)
http://www.hibernate.org/hib_docs/reference/en/html/mapping.html    [5.1.12 natural-id]

James Gregory

unread,
Jul 29, 2008, 4:28:53 PM7/29/08
to nhu...@googlegroups.com
That's a really good find Gabriel, I'll make an issue to make sure we don't forget about it! Thanks

Fabio Maulo

unread,
Jul 29, 2008, 5:11:59 PM7/29/08
to nhu...@googlegroups.com
2008/7/29 Gabriel Schenker <gnsch...@gmail.com>

ok. found it myself here in the Hibernate documentation (should search before ask...sorry)
http://www.hibernate.org/hib_docs/reference/en/html/mapping.html    [5.1.12 natural-id]

Grabriel... don't post nothing about natural-id in the blog...
It is NOT a NH2.0.0 feature.
It will be NH2.1.0 feature.
--
Fabio Maulo

Fabio Maulo

unread,
Aug 16, 2008, 1:06:28 AM8/16/08
to nhu...@googlegroups.com
Hi.
Gabriel,  <natural-id> now IS NH2.1.0 feature ;)

2008/7/29 Fabio Maulo <fabio...@gmail.com>



--
Fabio Maulo
Reply all
Reply to author
Forward
0 new messages