datamapper

How does the ActiveRecord pattern differ from the Domain Object or Data Mapper pattern?

I was looking at DataMapper, which appeared at first glance to use the ActiveRecord ORM pattern. Other people said that it uses the DataMapper and/or the Domain Object pattern. What is the difference between those patterns? ...

Mapping to Dictionary with iBATIS

Given a simple statement, such as: <statement id="SelectProducts" resultMap="???"> SELECT * FROM Products </statement> Is it possible to get a list of dictionary objects where the keys are the column names? ie. var list = Mapper.QueryForList<IDictionary<string,string>>("SelectProducts", null); IDictionary<string, string> dict = li...

Re-factoring from Active Record to Data Mapper

have you re-factored from an Active Record to a Data Mapper pattern? what conditions prompted the switch? i'm primarily interested in web based applications, but would like to know the challenges that accompany such a move in any environment. ...

Reusing a resultMap for different column names

Is there a way of reusing the same resultMap multiple times in a single query. For example, suppose I have a "foo" resultMap: <resultMap id="foo" class="Foo"> <result property="Bar" column="bar" /> </resultMap> Is there a way to define another resultMap that reuses the above for different columns? Something like... <resultMap id="...

Data Mapper Pattern

Up until now I've been using Active records in all my c# database driven applications. But now my application requires my persistence code being split from my business objects. I have read a lot of posts regarding Martin Fowler's data mapping pattern, but my knowledge of this pattern is still very limited. Let's use the following examp...

Class model to use in DataMapper

When implementing the DataMapper pattern, should the class model that I implement in the DataMapper package more closely resemble the domain model or the data model? ...

How to extend this simple DataMapper?

Can someone please derive a concrete example from the following: http://www.urdalen.com/blog/?p=210 ..that shows how to deal with one-to-many and many-to-many relationships? I've emailed the author some time ago but received no reply. I like his idea, but can't figure out how to implement it beyond simple single table relations. Not...

CouchDB + Datamapper + View = no ids

I'm using couchdbx v. 0.8.1 and datamapper 0.9.8. I've written a few simple views, copied some from other examples. If I query the views with a browser they return id's. If I query them using datamapper in ruby I get no id's. I've googled for days, been on IRC and looked through the couch and datamapper google groups. I've tried downgrad...

Data mapper pattern and automated updates of other objects

Hi, I'm building a PHP application using the data mapper pattern to separate my DB from the domain objects. I have a mapper class that returns Site objects based on data from the DB and accepts existing Site objects to be saved back to the DB. My problem is that in the system one (and only one) of all the sites has to be marked as the ...

Data Mapper pattern and duplicate objects

Hi, I'm using the data mapper pattern in a PHP app I'm developing and have a question. At present, you request a Site object with a specific ID and the mapper will lookup the row, create an object and return it. However, if you do this again for the same Site you end up with two different objects with identical data. eg.: $mapper = new ...

Data Mapper + Observer pattern

Hi, I'm building an app in PHP and I'm using the data mapper pattern for my DB access. I was considering using the Observer pattern to have all my mappers observe the entities they create, so that they can automatically save any changes back to the database without me having to parse them back manually. I was just wondering if this was...

How do I get make the in_memory adapter of the the ruby library DataMapper to save the model's id properly?

This regards the ruby ORM library DataMapper. This wiki describes how to use the in_memory adapter for DataMapper. The proper database adapters saves an incrementing, unique id on each model instance - in_memory doesn't seem to do that as shown by the following snippet: require 'rubygems' require 'dm-core' DataMapper.setup(:in_memory,...

Any other object-to-object mapping solutions other than AutoMapper in .NET?

I would like to know if the other similar open source solutions in .NET world, especially for 2.0 framework ...

Merb & DataMapper - accessing database connection info?

I'm using Merb and DataMapper with a MySQL db. I want to access the database name, user, and password from a Rake task for my Merb app. I guess I could YAML.load() the the database.yml, but that seems ugly. Any ideas? ...

Fowler Data Mapper Object Creation

I have been utilizing the Fowler patterns for domain models with a Data Mapper and have run into some confusion on how to implement the creation portion of CRUD. I can't utilize existing ORM technologies as the underlying data sources are custom systems. The area that’s troubling me is how to call the underling ORM when I need to create ...

Adjustments needed in a Rails app to use Datamapper instead of ActiveRecord

I am trying to use Datamapper in a Rails app as an alternative to ActiveRecord. I've followed the various setup instructions and have Datamapper working in my app. But one of the first things I noticed that no longer works is this: <%= f.error_messages %> I believe this is tied to an ActiveRecord helper - is there an alternative w...

Redirects with Datamapper & Rails

I have a line in my routes.rb to map my Album model as a resource: map.resources :albums However, using Datamapper in place of ActiveRecord in Rails, why would this line: format.html { redirect_to(@album) } cause a redirect to: albums/%23<Album:0x72d452c> instead of: albums/1 In case further context is needed, my full crea...

Select random data with DataMapper

Im trying to select random datasets with DataMapper, but seems like there is no such function support. For example, i have set of data: +-------------------+ | ID | Name | Value | +-------------------+ | 1 | T1 | 123 | | 2 | T2 | 456 | | 3 | T3 | 789 | | 4 | T4 | 101 | | ----------------- | | N | Tn | value | ...

How do you talk to a BerkeleyDB database from Ruby or Ruby on Rails?

I have no idea how I would set up a BerkelyDB database in a Ruby or Rails project. Does anyone have any experience configuring one, that they could talk about? Maybe using ActiveRecord or Datamapper? ...

Complex DataMapper query association

Hello, im a beginner with DataMapper ORM, so i have question about complex querying. First, here is simplified data objects: class User property :id, Serial property :login, String has n, :actions end class Item property :id, Serial property :title has n, :actions has n, :users, :through => :actions end ...