Forum: Ruby on Rails Active Record vs Data Mapper

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A049c3597983fdaaa2af2b0010c49abc?d=identicon&s=25 Tim Perrett (timperrett)
on 2007-03-26 22:07
Hey guys

Ive been doing some backgronud reading on the whole ORM scenario as i
was intersted in where AR actually came from and i can obviously see
what it was that AR has developed in the way that it has:

  - ease of use
  - maintanible
  - lots of functionality

and lots more stuff. But i was wondernig what happens when people want a
more complex domain model than the one that AR faciliates? are there any
options out there already for other types of ORM within ruby? Ive looked
into Og, but i cant see that it is particularly clean to use on first
glance.

I guess my question is this:

How are people using AR with complex domain logic, and if they are using
somthing other than AR to do it, what is it?

Cheers

Tim
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 Rick Olson (Guest)
on 2007-03-26 23:18
(Received via mailing list)
On 3/26/07, Tim Perrett <rails-mailing-list@andreas-s.net> wrote:
>
> and lots more stuff. But i was wondernig what happens when people want a
> more complex domain model than the one that AR faciliates? are there any
> options out there already for other types of ORM within ruby? Ive looked
> into Og, but i cant see that it is particularly clean to use on first
> glance.
>
> I guess my question is this:
>
> How are people using AR with complex domain logic, and if they are using
> somthing other than AR to do it, what is it?

Look at rBatis, possibly?  https://rubyforge.org/projects/rbatis/


--
Rick Olson
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com
A049c3597983fdaaa2af2b0010c49abc?d=identicon&s=25 Tim Perrett (timperrett)
on 2007-03-26 23:21
>
> Look at rBatis, possibly?  https://rubyforge.org/projects/rbatis/
>

I did see that, I had a poke around in the RDoc, but it seemed to use a
lot of configuration? Has anyone actually used RBatis enough to comment
on what it works like? I am aware of iBatis from java, but we always
used hibernate so im not sure how it compares?

Cheers

Tim
9a71df6388c8d37bfdf0e18742ea944a?d=identicon&s=25 AndyV (Guest)
on 2007-03-27 06:00
(Received via mailing list)
rBatis has given me an incredible appreciation for AR!

In most cases, you'll find it very similar to hibernate.  Yes, with
rBatis you're buying more configuration time for yourself.  It's a bit
more of a purist ORM tool in that respect.  With rBatis you can
completely decouple your domain from the relational DB because of the
configuration (mapping) that you provide in the domain class.  If I
had a complaint about rBatis it's that it doesn't quite drive the ORM
concept far enough since the mapping actually resides in the domain
class.

AR is a different approach all together.  The intention of AR is
essentially to wrap an object around a DB row.  Practically speaking,
though, I have not seen a lot of hibernate/iBatis solutions that
really push far from this 1:1 correspondence.  If you can settle the
lost flexibility in your own mind, you'll gain a great deal of
productivity by skipping the configuration.

Just curious -- what types of complex domain logic do you reckon would
be beyond the capability of AR?


HTH,
AndyV

On Mar 26, 5:21 pm, Tim Perrett <rails-mailing-l...@andreas-s.net>
A049c3597983fdaaa2af2b0010c49abc?d=identicon&s=25 Tim Perrett (timperrett)
on 2007-03-27 10:02
> Just curious -- what types of complex domain logic do you reckon would
> be beyond the capability of AR?

Nothing in particular, i just wanted to start a conversation about it as
i think its facinating. I read an interesting post on one of the prag
prog blogs the other day where dave i think it was, was talking about
wrapping AR models up in presentation classes to keep the domain logic
seperate from AR - sounded like another layer on of abstraction on some
instances of AR

Have you ever heard of this?

Tim
Ab4f2861e1f40c2092c09ba993a87462?d=identicon&s=25 rschenk@gmail.com (Guest)
on 2007-03-27 15:52
(Received via mailing list)
I have an extraordinarily normalized database, which I'm having a lot
of trouble modeling with AR, because there simply cannot be a 1:1
correspondence between an object and a DB row. I have hacked a
solution that works fair, but is not perfect.

Thanks for the rBatis link, I'm going to check it out! I hadn't heard
of it before, and it might be just what I need for modeling one
particular part of our database.

In our database, we have 3 normalized tables for product
configurations. One table, the config_items table, holds the value of
the configuration item as a varchar, and a foreign key to our
config_types table. The config_types table stores a description of the
config_item, the mysql datatype of the config_item as a varchar, for
instance "tinyint", and a foreign key to the config_families table,
which simply stores a varchar name for the configuration family (or
category).

For instance,
one config_item's value might be "Windows XP", which is linked to a
config_type with the description "operating system" and data type
"varchar", which is then linked to a "software" config_family.

I've got an AR model named SoftwareConfigurations, which will extract
all of the config_items and related config_types who are linked to a
config_family of "software". When the SofwareConfigurations class is
defined, I build new AR::ConnectionAdapters:Columns for each
config_type, using it to automatically cast based on the datatype
string stored in config_types. This way, I can say something like
software_config.operating_system, and it would return back "Windows
XP" as a string. It works, but I'm not sure how robust it will be. And
frankly, something like this, really ISN'T an ActiveRecord, IMHO.
Maybe rBatis will be just the ticket.

On Mar 27, 4:02 am, Tim Perrett <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.