Meta-NHibernate?!

25 views
Skip to first unread message

Alex Maines

unread,
Feb 7, 2012, 12:50:32 PM2/7/12
to Fluent NHibernate
Dear all

I recently wrote my own ORM system (long story). It is basic but very
effective. It has no known bugs, but few of the features of a
sophisticated ORM tool like xHibernate. I do think it could be
extended to have more features if that were required but it has never
been necessary.

My starting point was to use metadata for mapping the relationships,
stating the relationship between each entity class's properties and
the corresponding columns in the DB as attributes, like so

[DataColumn("ID", SqlTypes.Int16), PrimaryKey]
public int ID { get; set; }

This also allowed me to declare custom type converters for marshalling
types from my Oracle DB to .Net (eg converting 0/1 to boolean T/F
where the Oracle SPs returned NUMBER values).

I have three questions for the group.

Question (1): does Fluent Hibernate provide anything like this as a
mapping strategy?

If not.....

Question (2): is it a bad idea in absolute terms? Can anyone think of
a killer argument against it as a design pattern (nearest comparison
without betters samples/screenshots is the DataContract pattern in
WCF).

Question (3): if everyone does like the idea, how do people feel about
adding it to Fluent NHibernate or branching to create a new product
called something like Meta NHibernate?

Please note that the answer to question (2) is not that it is harder
to pronounce....

Looking forward to any comments anyone may have.

Alex

Zvjezdan Tomičević

unread,
Feb 8, 2012, 5:57:55 AM2/8/12
to fluent-n...@googlegroups.com
Checkout DevExpress ORM XPO

> --
> 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.
>

Oskar Berggren

unread,
Feb 8, 2012, 7:37:44 AM2/8/12
to fluent-n...@googlegroups.com
2012/2/7 Alex Maines <alexmaines.so...@gmail.com>:

> Dear all
>
> I recently wrote my own ORM system (long story).  It is basic but very
> effective. It has no known bugs, but few of the features of a
> sophisticated ORM tool like xHibernate.  I do think it could be
> extended to have more features if that were required but it has never
> been necessary.
>
> My starting point was to use metadata for mapping the relationships,
> stating the relationship between each entity class's properties and
> the corresponding columns in the DB as attributes, like so
>
> [DataColumn("ID", SqlTypes.Int16), PrimaryKey]
> public int ID { get; set; }
>


Seems similar to this:
http://nhforge.org/doc/nh/en/index.html#mapping-attributes

/Oskar

Rasmoo

unread,
Feb 8, 2012, 7:52:24 AM2/8/12
to Fluent NHibernate
James Gregory replied to a similar question once. I think it sums it
up alright.

http://stackoverflow.com/questions/680147/nhibernate-fluent-vs-attributes

On Feb 7, 6:50 pm, Alex Maines <alexmaines.softwareengin...@gmail.com>
wrote:

Tim Scott

unread,
Feb 8, 2012, 9:02:37 AM2/8/12
to fluent-n...@googlegroups.com
Castle ActiveRecord also has mapping via attributes.  A little simpler and more convention-based than NH attributes (if memory serves).  You can use these attributes only for mapping if you want and use NHibernate directly instead of ActiveRecord.  I did that once some years ago.

People seem to favor fluent code based mapping probably because it reduces cruft in entities and offers the possibility of auto mapping.

Joe Brockhaus

unread,
Feb 8, 2012, 9:51:41 AM2/8/12
to fluent-n...@googlegroups.com
I just want to add that I don't think requiring your entities to have properties virtual or protected should be considered 'clean' and amounts to /not/ muddying up your model. 

There are times when it forces funky workarounds. Not the end of the world, but it's something to consider. I'm not even sure if in NHproper you have to do this, but I'm thinking it's the case.

------
Joe Brockhaus
joe.br...@gmail.com
------------
Reply all
Reply to author
Forward
0 new messages