# Hibernate on Ruby

**URL:** <https://www.ruby-forum.com/t/hibernate-on-ruby/50090>\
**Category:** Ruby\
**Created:** [December 12, 2005, 10:49pm UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090 "2005-12-12T22:49:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 12, 2005, 10:49pm UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/1 "2005-12-12T22:49:54Z")

</div>

Any ideas on using Hibernate OR/M from within Ruby?

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 12, 2005, 10:52pm UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/2 "2005-12-12T22:52:54Z")

</div>

Why, when you have Og, ActiveRecord and a few other interesting  
choices?

T.

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 12, 2005, 10:58pm UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/3 "2005-12-12T22:58:55Z")

</div>

ActiveRecord is great for small-to-medium things, but does quickly show  
it’s limits on large things. NOTE: Please, do not turn this thread  
into a flame war. See Martin F.'s discussion of ActiveRecord  
versus DataMapper. Rails’s ActiveRecord is based on Fowler’s  
ActiveRecord pattern, wheras Hibernate is a DataMapper, which Fowler  
himself favors for complicated mappings.

See DHH’s post:  
“No, you don’t get the full offer of opportunities that straight OO  
with a data mapper holds. I’d like to think, though, that Active Record  
gives you 80% of the features for 20% of the effort.”  
[http://www.loudthinking.com/arc/000209.html](http://www.loudthinking.com/arc/000209.html)

Example for me:  
Let’s say I have a class hierarchy, in which a particular field is  
stored direclty in the db for one class, and calculated using a simple  
SQL formula for other other classes. How can I use the DB to query the  
tree for all objects where field == aVal.

Answer: In ActiveRecord - you can’t (w/o major hacking). You need to  
instantiate each one from the db, and then use Ruby to check each one.

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 12, 2005, 11:54pm UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/4 "2005-12-12T23:54:52Z")

</div>

List R. wrote:

> ActiveRecord is great for small-to-medium things, but does quickly show  
> it’s limits on large things. NOTE: Please, do not turn this thread  
> into a flame war. See Martin F.'s discussion of ActiveRecord  
> versus DataMapper. Rails’s ActiveRecord is based on Fowler’s  
> ActiveRecord pattern, wheras Hibernate is a DataMapper, which Fowler  
> himself favors for complicated mappings.
> 
> See DHH’s post:  
> “No, you don’t get the full offer of opportunities that straight OO  
> with a data mapper holds. I’d like to think, though, that Active Record  
> gives you 80% of the features for 20% of the effort.”  
> [http://www.loudthinking.com/arc/000209.html](http://www.loudthinking.com/arc/000209.html)
> 
> Example for me:  
> Let’s say I have a class hierarchy, in which a particular field is  
> stored direclty in the db for one class, and calculated using a simple  
> SQL formula for other other classes. How can I use the DB to query the  
> tree for all objects where field == aVal.
> 
> Answer: In ActiveRecord - you can’t (w/o major hacking). You need to  
> instantiate each one from the db, and then use Ruby to check each one.

Google up Og and Kansas and see if either suits you better.  
Both take a modeling approach perpendicular to AR. There  
are others also, I am sure.

Or, of course, you could restructure your data 🙂

E

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 13, 2005, 2:50am UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/5 "2005-12-13T02:50:50Z")

</div>

Zed A. Shaw wrote:

> No, that’d actually involve admitting he is wrong. The day a  
> programmer actually admits he’s wrong is the day Satan ice skates  
> around Times Square in July eating Tasti-Delight while wearing long  
> underwear.

Yeah, that’s the way, go off on a tangent and berate someone for asking  
a simple question, without actually giving him a straight answer.

Now I remember why I unsubscribed from this group before…

–  
Neil S. - removed\_email\_address@domain.invalid

‘A republic, if you can keep it.’ – Benjamin Franklin

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 13, 2005, 2:41am UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/6 "2005-12-13T02:41:47Z")

</div>

On Tue, 13 Dec 2005 07:55:02 +0900  
Eero S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Google up Og and Kansas and see if either suits you better.  
> Both take a modeling approach perpendicular to AR. There  
> are others also, I am sure.
> 
> Or, of course, you could restructure your data 🙂

No, that’d actually involve admitting he is wrong. The day a  
programmer actually admits he’s wrong is the day Satan ice skates  
around Times Square in July eating Tasti-Delight while wearing long  
underwear.

For another great example of “fighting to always be right” refer to any  
thread about plural table names (either side).

Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 13, 2005, 4:38am UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/7 "2005-12-13T04:38:59Z")

</div>

Thanks for the support Neil.

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 13, 2005, 3:34pm UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/8 "2005-12-13T15:34:58Z")

</div>

On 12/12/05, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks for the support Neil.

I won’t claim to support this idea. Personally, I think it’s like  
having your whole BMW chromed. Heh.

However, you should be able to actually do it with something like:  
[http://rjni.rubyforge.org/](http://rjni.rubyforge.org/)  
…or:  
[http://raa.ruby-lang.org/project/rjb/](http://raa.ruby-lang.org/project/rjb/)

I’m not sure if there’s a good way to gen the XDoclet tags in Ruby.  
Presumably there’s a fancy ERb trick you can use.

---

<div class="post-metadata">

**Author:** ![lstrecv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@lstrecv](https://www.ruby-forum.com/u/lstrecv)\
**Post date:** [December 13, 2005, 11:03am UTC](https://www.ruby-forum.com/t/hibernate-on-ruby/50090/9 "2005-12-13T11:03:50Z")

</div>

removed\_email\_address@domain.invalid ha scritto:

> Any ideas on using Hibernate OR/M from within Ruby?

probably the only chance is using jruby, but are you sure you can’t do  
what you want with Og ?
