Object-relational mapping (ORM) is a technique for mapping between object-oriented systems and relational databases.

learn more… | top users | synonyms

7
votes
3answers
159 views

How to model and store an entity which has “one or more” values

I'll use C# to design the model to be persisted Let's suppose I have the following entity: public class Episode { public int Id { get; set; } public string Title { get; set; } public ...
8
votes
2answers
200 views

Best practices for serialization of DDD aggregates

According to DDD domain logic should not be polluted with technical concerns like serialization, object-relational mapping, etc. So how do you serialize or map the aggregates' state without publicly ...
0
votes
0answers
39 views

Entity Framework and separating DAL from domain entities

If I have a normalized db, it's unlikely to map 1 to 1 with my domain entities. So I customize my EF entities to fit the domain. But now my EF entities are essentially my domain entities and my DAL is ...
2
votes
1answer
52 views

Creating/updating entity save strategy

Please note: although I'm talking about Java in this question, what I'm asking about here should really be language-agnostic. I am dabbling in OR/M for the first time, and have cooked up the ...
0
votes
0answers
35 views

Programmatically extending table/entity definition mappings through aspects in Spring and Hibernate

I would like to know if it is possible to use AOP to extend table/entity definitions so that I can add functionality across the board that requires persistence. Let me explain what I want to do with ...
2
votes
5answers
153 views

Stored Procedures, ORMs and other application layers

I'm just starting out on a project to develop a new, fairly substantial web application which has an underlying MSSQL database. We're hiring a team of developers to write the application (in .NET) and ...
0
votes
0answers
21 views

Syncing structured data and files in Android App with an ORM?

I am developing an Android App which I have developed for iOS before. The app requires that structured data and files are synced across android devices. In iOS, I was using Core Data and synced to ...
0
votes
0answers
9 views

compare different approachs for saving related records whose values may change

On a web application for accounting services, I have the good old Invoice. To keep this example as simple as possible, each Invoice has many rows, and each row has its item with its price. At the ...
0
votes
1answer
49 views

Control (avoid) changing fields with side-effects

I have been thinking about a design problem and possible solutions in my own. I am pretty sure I am not the first one to have noticed it, but I cannot google for it since I do not know the standard ...
0
votes
1answer
69 views

Inverse property naming (ORM scenario) [closed]

I have a class that represents a process. In this process there are inputs boxes and output boxes. public class Process { public long ProcessId { get; set; } public virtual List<Box> ...
2
votes
2answers
57 views

How to ORM non-disjoint specializations

Consider this highly simplified sample of relational data (each table may be involved in one-to-many and many-to-many relationships not shown here): people +-------+------+--------+ | name | born | ...
2
votes
2answers
64 views

Domain/Model objects attributes good practices

Simple question: Should model/domain objects only include attributes that are meant to be persisted in a database or serialized to any other specific format? My understanding of a domain/model object ...
0
votes
0answers
26 views

Managing allocation calendars for an employee set [duplicate]

IN view of creating a MIS (Management Information System) one architectural/design issue that's confronting us is managing allocation for set of employees. Scenario: Employees get allocated to ...
6
votes
4answers
383 views

Heterogeneous Associations - Data Modeling When an Object that Must Relate to One of Many Classes

Suppose you have 3 classes: ClassA, ClassB and ClassC. Now suppose you have a class Message. You want a one-to-many relationship between each one of those three classes and the Message. The goal is ...
1
vote
1answer
63 views

How to associate both a collection and one item of this collection to an entity

I'm working on a project in which I have an entity, we may call Users and another entity Address. I want to define the entity User in a way that an user would have a collection of addresses ...
0
votes
1answer
28 views

Migrating single-layer ORM based app to multi-layer API

I'm trying to understand what is the best way of migrating a website that works in a single layer and gets all the data via an ORM, to one that uses multiple layers, using an API backend to get the ...
0
votes
1answer
94 views

Real time middleware system: Direct DB access vs REST API access

I'm developing a complex environment which involves a web application, a mobile app and a real time middleware system which accesses the DB for on-site tag readings. Currently, the web application ...
2
votes
1answer
96 views

Finding a way to simplify complex queries on legacy application

I am working with an existing application built on Rails 3.1/MySql with much of the work taking place in a JavaScript interface, although the actual platforms are not tremendously relevant here, ...
-1
votes
2answers
124 views

Data Access Objects old fashioned? [closed]

A couple of weeks ago I delivered some work for a university project. After a code review with some teachers I got some snarky remarks about the fact that I was (still) using Data Access Objects. The ...
1
vote
2answers
193 views

Limitations of the Identity Map pattern

After asking about the implementation in Ruby of the Identity Map pattern because the potential memory leak in long running server apps, I am considering my initial concept of that pattern. Initially ...
0
votes
2answers
521 views

Proper Query Object Pattern - NHibernate

I was looking to an alternative to Repository Pattern and I've read about "Query object pattern" (http://lostechies.com/jimmybogard/2012/10/08/favor-query-objects-over-repositories/). However the ...
0
votes
0answers
50 views

Extending database model of ORM in subproject

I have a maven project which contains some entities which are stored in a database. The purpose of this project is to manage personal information, users, locations, etc. This project can work on its ...
1
vote
2answers
105 views

How far can I drift from my original domain model and still have the benefits of an ORM?

I have the following domain models: public class User { public int Id { get; set; } public ICollection<Product> Products { get; set; } } public class Product { public int Id { ...
0
votes
1answer
157 views

Doctrine 2 and Concrete table inheritance

I use Doctrine 2 and I've read some articles on inheritance strategies' mapping with ORM. I've seen three main strategies : "Class table inheritance", "Concrete table inheritance" and "Single table ...
1
vote
1answer
159 views

PHP - Repository matrix pattern?

I'm trying really hard to refactor some of my legacy code in the project using best practices and design patterns + DDD so I'd love some feedback on an issue I'm currently having. Let's assume that I ...
-2
votes
1answer
262 views

How to use ORM in MVC?

If I want to use ORM in MVC system Which is/are correct? Use ORM object to replace Model Encapsulate ORM inside the Model Use ORM outside the Model, use ORM to access DB, and then use one instance ...
0
votes
0answers
52 views

Example of persisting an inheritance relationship using ORM

I have some experience with OOP and RDBs, but very little exposure to web programming. I am trying to understand what non-trivial types of problems are solved by ORM. Of course, I am familiar with the ...
1
vote
1answer
205 views

How do you handle domain logic that spans multiple model objects in an ORM?

So I know that business logic should be placed in the model. But using an ORM it is not as clear where I should place code that handles multiple objects. E.g. let's say we have a Customer model which ...
0
votes
1answer
261 views

Many-to-many in OOP: Class A instantiates Class B, which instantiates Class A, which

I am mapping Field1 to Field2. The map object instantiates the field object and vice versa, creating an infinite loop. This is in PHP. class field { protected $maps; // mapCollection object. all ...
2
votes
1answer
192 views

Persistence frameworks and common sense

I have studied some persistence frameworks mainly Hibernate, DORM, TMS Aurelius and I'm wondering. In a model of type: TOrderFiscal < > ----- > Items < > -------- > TOrderItem ...
0
votes
1answer
76 views

DB Design: How to link a single column to a collection of entities

I have a db design question that I am sure has been quite extensively covered but I cannot find a good answer already. The problem is how to efficiently link a single school course to a collection ...
3
votes
5answers
206 views

Is it bad software design to mix JDBC SQL calls and use an ORM in an application? [closed]

Is it bad software design to have JDBC/raw SQL and also use an ORM? I don't mind using an ORM for boilerplate CRUD, but some queries are better in SQL (for me). I'm not arguing for or against ORMs. ...
4
votes
4answers
5k views

How to get around the Circular Reference issue with JSON and Entity

I have been experimenting with creating a website that leverages MVC with JSON for my presentation layer and Entity framework for data model/database. My Issue comes into play with serializing my ...
3
votes
3answers
418 views

How does accumulating large amounts of business logic on the model objects make building strong service contracts harder?

I heard a couple of times that putting business logic in database models is bad down the road. I just read this in blog of a Rackspace employee: The Django ORM also tended to have us accumulate large ...
-2
votes
1answer
110 views

Finding next free IP in a network

I have an IP network and want to automatically find a free IP address to provision a new server. Due to frequent server additions/removals the used IPs might be quite fragmented over the whole address ...
2
votes
1answer
348 views

What kind of object relational mapping is appropriate here?

In my database I have a table that looks like this Master(ID, Name, Attr1...). Every ID will have at least 1 entry in additional tables that have additional attributes. Those tables specialize the ...
0
votes
1answer
922 views

Android: Considering an ORM tool [duplicate]

I am developing an Android app in which I have to add chat functionality. Also, I have to save the chat history. I will accomplish this task using SQlite. But, I am not sure whether should I consider ...
1
vote
0answers
199 views

Benefits of using object document mapping (ODM)

I am creating a web app on Flask and was planning to use mongodb. Most of the examples using this stack that I've come across have used an ODM of some kind and was wanting to figure out whether or not ...
0
votes
1answer
531 views

Audit trails and entity relationships

I'm working on an order system and implementing an audit log. Two main concerns are: 1) While auditing a line item , you should only see audits for the line item 2) While auditing an order, you ...
1
vote
2answers
175 views

Setter Validation can affect performance?

In a scenario where you use an ORM to map your entities to the DB and you have setter validations (nullable, date lower than today validation, etc), every time the ORM gets a result, it will pass into ...
7
votes
1answer
1k views

Is inline SQL still classed as bad practice now that we have Micro ORMs?

This is a bit of an open ended question but I wanted some opinions, as I grew up in a world where inline SQL scripts were the norm, then we were all made very aware of SQL injection based issues, and ...
11
votes
4answers
2k views

When to use repository pattern

I have read recently that it is not good practice to use the repository pattern in conjunction with an ORM. From my understanding this is because the abstraction they provide over the SQL database is ...
3
votes
1answer
174 views

ORM: Design of the service layer

I'm currently writing a medium sized web-application and find myself asking this question many times. For example, let's say there are users, which have files (one-to-many). How should the UI access ...
1
vote
1answer
69 views

When using an ORM should mappings be defined in the code file?

Doctrine offers three ways to define the object mapping properties: in XML, in YAML and as inline docblock annotations in the code. The Doctrine documentation doesn't give any advice on choosing ...
0
votes
1answer
77 views

raw aql query in framework with Active Record pattern based ORM

I use yii framework that implements Active Record pattern as ORM base. It has CActiveRecord class that is a table wrapper class with attributes reflecting table columns. So each object of this class ...
5
votes
4answers
712 views

Performance related doubt in Java with Hibernate

Suppose in some ORM based project (say Hibernate) I am trying to fetch only few columns rather then the whole Object with may be more than 20 attributes. I am writing HQL like "select attr1, attr2 ...
1
vote
2answers
133 views

Getting related foreign keys from parent entities

I'm thinking about a design issue which affects my project's data base. Supposing there are three diferent tables: CLIENT ORDER PACKING_SLIP Each order has its client and different packing ...
2
votes
2answers
488 views

NHibernate and complex domain model against a legacy database

I'm trying to refactor (actually, rewrite) an application which currently uses only stored procedures to access the database (hundreds of SPs). My goal is to use Nhibernate and follow a good design as ...
3
votes
1answer
241 views

What specific features of NHibernate cause it to be recommended for legacy database systems?

So, I've been evaluating Entity Framework and NHibernate (I'm not looking for an EF vs. NH battle here, though!). One thing that I see come up very often is that NHibernate is recommended for ...
4
votes
3answers
162 views

What is a good rule-of-thumb for naming link-tables?

In the same way that a publication table might relate to a person table via subscriptions, or a company table might relate to a person table via employee, I'm wondering if there is a descriptive way ...