views:

676

answers:

2

Is there something like Fluent-NHibernate for the original Java Hibernate? If not, why not? Are there any language-specific limitations?

+5  A: 

I believe Fluent-NHibernate relies on the nice features provided by Linq in C#3.0 if I'm not mistaken. Until Java implements lambda expressions etc I don't think we'll see Fluent Hibernate.

I could be wrong though. :)

mezoid
good point. I was concentrating on the fluent style interface and was wondering if this is a problem and couldn't found any. But inside the concatenated calls there are lambda expressions, doh!
Marc Wittke
From the horses mouth (I'm the lead developer on Fluent NHibernate): the reason Fluent Hibernate doesn't exist is exactly because of the lack of lambda expressions. It's not just the lack of basic lambdas, but the ability to parse those expressions that FNH relies heavily on; without which you'd need to resort to strings and that's no better than XML in my opinion. It's always a possibility for the future though.
James Gregory
@James: While using lambdas as data is cool, I find the convention based mapping is my primary motivation for using FNH. It's insanely easy to "get something working", and then lock down the schema later. The only problem I see is the fact that the nested closure pattern is used throughout FNH; while that works well with C#, Java doesn't have support for anonymous methods (although you can create functors via anonymous classes). I think Fluent Hibernate would work quite well in Scala, and it could kinda sorta work in Java.
Charles
A year after making my comment, my thoughts pretty much mirror yours. If you feel like discussing this further, drop a message on the [FNH mailing list](http://groups.google.com/group/fluent-nhibernate).
James Gregory
A: 

Groovy supports lambda expressions (although they rather confusingly call them closures), and Groovy classes are directly accessible from Java. Perhaps the mappings for Java apps could be written in Groovy.

Just a thought.

Michael S. Kelly