Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [orm]

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

0
votes
1answer
45 views

Updating sub-properties via Entity Framework

I was wondering how to updated nested objects/sub-properties when using Entity Framework. But to make things clear, let's start with an example. I have an object, which can own a number of other ...
0
votes
1answer
86 views

Any solid reason to have getters/setters in entities? ORM, Doctrine

I've been trying to decide if I should include getters/setters in business entities. A few reason I have been through to include getters/setters but those are accompanied by an anti-reason as well. ...
4
votes
1answer
72 views

Maintaining parallel libraries: Binary files access + Metadata Database ORM design

I'm dealing with a higher-level data abstraction that I would appreciate some input on. I'm working on an application that uses a large data lake. The data lake is consisted of thousands of large ...
3
votes
2answers
377 views

Should Entity Framework 6 not be used with repository pattern?

So I am asking this after reading the following: Why shouldn't I use the repository pattern with Entity Framework?. It seems there is a large split of people who say yay and those that say nay. ...
0
votes
1answer
63 views

Entity Framework and static entity instances

I'm always having the problem on how to properly design having static entity instances and it being attached to Entity Framework's Dbcontext. For example, we have the following: using Microsoft....
1
vote
1answer
51 views

Using frameworks that map database to RESTful APIs?

While researching RESTful API frameworks I've come across (generally speaking) two types of frameworks: The first type will (more or less) directly (or nearly directly) map an ORM/ODM scheme of your ...
-1
votes
1answer
63 views

Patterns for loading related objects in memory (without an ORM)

I am using ADO.NET to read a bunch of data from the database into in-memory objects. This is my domain model: // Question.cs public class Question { public int ID { get; set; } public ...
0
votes
1answer
63 views

How to handle different pages of a web application having different levels of access to a database model

I am working on an ASP.NET Core application that grabs a model from a database via Entity Framework, and will pass a "subset" of that model to our Angular front end. For example: I have a list of ...
0
votes
1answer
84 views

Private class in ORM Repository?

Is this a code smell? I have a repository which connects to a SQL server. This repository uses Dapper to map the results to an object. I have a method in this repository that checks a result, then ...
1
vote
1answer
101 views

How to handle a many to many relationship with an ORM mapped to a Domain Model when there are no technical constraints?

Domain Driven Design states that you should have a domain model, which reflects the ubiquitious language used by the domain experts. When using ORMs and many to many relationships I am use to doing ...
1
vote
2answers
156 views

Encapsulation and input validation duplication

Consider the following example (very simplified): public class Basket { private readonly List<BasketItem> _items = new List<BasketItem>(); public IReadOnlyCollection<BasketItem&...
2
votes
1answer
377 views

How should I design a 3-tier-architecture application with Entity Framework?

This is almost getting me crazy. EF bring us a very convenience experience in development. However, if we need to use the Entity model in the upper layer, we always put a reference from the upper ...
-1
votes
1answer
52 views

Calculating time an object stays in a state

I use Python sqlalchemy to store my model in a MySql database. One of my objects has a 'state' field (for simplicity let's assume there are two states: AVAILABLE and UNAVAILABLE). There are ...
1
vote
2answers
117 views

When using an ORM when should I sacrifice performance for convenience?

I work with SQL Alchemy a lot and, as a "lazy programmer", I enjoy the convenience it offers. But the "diligent programmer" in me often worries about optimisation and the performance of the queries ...
3
votes
2answers
847 views

Separating Domain Object and Data Models

I looked through a lot of articles, blogs, and SO topics about separating domain object and data models. Almost every answer said: You should have separate classes for the domain and data persistence, ...
28
votes
5answers
10k views

Should I check if something exists in the db and fail fast or wait for db exception

Having two classes: public class Parent { public int Id { get; set; } public int ChildId { get; set; } } public class Child { ... } When assigning ChildId to Parent should I check first if ...
1
vote
0answers
307 views

Handling complex dynamic queries in Laravel 5

I am developing a project using Laravel. My workflow is: route directs to controller Controller calls eloquent models Eloquent models perform queries (tipically CRUD and find) Controller returns ...
1
vote
1answer
297 views

Entities and polymorphic relationships

Lets say that I have a shelf on which I can put items that are shelfable (not sure if that is actually a word but you can understand my point). So I have the following: class Shelf { /** @var ...
1
vote
4answers
94 views

How do I approach structuring when to read/write objects to db?

This is a problem I've faced in many languages over the years (js, go, c, f#, haskell, python, ...), but I haven't found a general approach to solving this yet. Learning about consistency models in ...
-1
votes
1answer
511 views

ORM vs Web API differences

I'm struggling to understand the differences between an API such as a REST API and an ORM such as Entity Framework. I would also like to understand the benefits of each and in what situations either ...
1
vote
1answer
96 views

How can I model unknown and an unknown number of attributes on an object?

My example might be slightly contrived, because I've modified it so that the project isn't recognizable by my employer. I'm a newer developer at a very small company. We have an object - Posts - that ...
0
votes
2answers
75 views

Best practice for object relation mapping to execute delete/update

In doctrine (or any ORM in general), the easiest way to execute a delete/update operation is to select such entity, then remove entity or update single attribute in the code, ended by persist the ...
0
votes
1answer
293 views

Data Mapper Pattern and DDD - Does ist already reflect domain entities and repositories?

I'm getting used to DDD so don't assume I'm a DDD pro yet. I'm trying to implement a hexagonal architecture using the CakePHP framework in a completely custom made application that just utilizes the ...
2
votes
1answer
50 views

Should the ORM create the related objects (ForeignKey objects) when saving the entity?

This question is coming from a frustration when using the Entity Framework and ASP.NET MVC, but I assume it's a general frustration across more frameworks and languages. Lets say we have an object ...
5
votes
1answer
154 views

Split ORM module without creating cyclic imports or side-effects

Preface I have an ORM library for a relational real estate database. The used framework is peewee. The library contains ~60 models, each representing a distinct table. The models represent a (pre-...
1
vote
1answer
117 views

ORM for 600 tables

I am working on a huge application in php which contains almost 600 tables to work with, not to mention it requires complex joining for 10 or 15 tables together. i wanted to ask how much ORM is good ...
3
votes
1answer
133 views

Database modeling. Many to Many relationships. Link tables

Consider a database table for user info like: id, name, email now consider I have another table for video something like: id, name, description, length Say a many to many relationship exists ...
2
votes
1answer
38 views

Advice on AggregateRoot boundaries

I am confused on how to apply DDD principles for the design of domain entity clusters with Aggregate Root. According to my understanding, Aggregate Root enforces business validations and all entities ...
4
votes
1answer
276 views

Routing all SQL queries through a single micro-service

I currently have a website, made of about 20 micro-services and a (still too large) main monolithic web application. The monolith and multiple micro-services each run queries to the same database, ...
1
vote
2answers
480 views

Ways to store objects, inherited from one superclass in a database

For my personal project I need to store 2D shapes in a Postgres database. For example Circle, Pentagon, Rectangle and so on. At first I've done it like so: all shapes are inherited from an abstract ...
-2
votes
1answer
83 views

Is generating Hibernate Entities from database tables considered a bad practices?

On my current project it is a common practice to generate Hibernate Entities from database tables using NetBeans functionality. I'm normally used to first write the Entity-class and define the mapping ...
1
vote
1answer
156 views

Is there a better design than reflection to deal with large numbers of ORM objects?

Here's a scenario I've encountered variations of on many occasions. Imagine an XML feed which displays data about three different types of event: concerts, plays and movies. Each has a different set ...
2
votes
2answers
113 views

Object that can set its own subclass/amend its methods with subclass?

I have a database that stores client data. All data is in one table. For each client, there is one row per day. Clients have different kinds of contracts, their data format remains the same, however, ...
3
votes
1answer
224 views

Data access design pattern

I've several cases where a single entity has multiple tables in the underlying database. When reading or writing I want to handle all of the DB queries with a single class for that object, e.g., the ...
0
votes
2answers
187 views

Where should I put the database access method in a treeview environment

I have written a class to represent 'Treeview-like' data, which can be simplified as: public class Item { public string Name { get; set; } public KPI AssociatedKPI { get; set; } public ...
2
votes
1answer
1k views

Table Per Concrete Type in Entity Framework Core

I'm trying to port code from entity framework 6 (EF6) to entity framework core 2.0 (EF-Core) and have ran into a dead end. In my EF6 code, I have a base class called Record which defines the base ...
1
vote
1answer
1k views

Service layer with DTO

I'm refactoring my desing to use a service layer - however I'm confused about how you would pass arguments, when it's only allowed to update certain fields of the entity. For instance I have some ...
0
votes
4answers
304 views

The Open/Closed Principle, how does it work for adding entities?

I'm not even sure how to ask this, but here goes: Let's say I have a Web application that incorporates Teachers, Courses and Students in such a way that I can do things like this (pseudocode): ...
2
votes
2answers
646 views

Object To Be Used By Service Layer

My project has a UI layer, a Service Layer and a Repository layer. The latter has Entity objects as part of the ORM (.net Entity Framework). The service later returns a Dto to the UI layer. My ...
-3
votes
1answer
63 views

Dynamic query building for report generation tool : suggestion for better approach

I have a requirement for a reporting tool in which the user will be selecting the "class" that has some associated column and "filter" option in the view. Each class is associated with a list of ...
0
votes
1answer
96 views

Dry refactoring against database

Our database has an Attribute table and a WorkItem table that are in a many to many relationship using a WorkItemAttribute table. The WorkItemAttribute table contains the foreign keys for each and a ...
0
votes
2answers
60 views

Class For Summarised List Of Complex Objects

Assume I have a class that represents a complex domain object with dozens of properties, such as a pension policy. The GUI lists all pensions in a summary table that only contains a small subset of ...
11
votes
8answers
3k views

Unifying programming and database query [closed]

Consider a common tutorial for object-oriented programming languages like C++ or Java: create a simple order processing system with objects representing accounts, orders, items etc (or something more ...
0
votes
1answer
795 views

Using Laravel with DAO instead of Eloquent ORM

We have a complicated ERP software written in native PHP and our own micro-framework which uses big and complicated queries. We want to rewrite the application using an MVC framework (e.g. Laravel). ...
5
votes
3answers
547 views

Stored procedures or ORM in web?

I am working in a Peruvian company that develops desktop accounting software(.net C#). We have many clients (companies) each customer can create several companies, in addition there is a new database ...
3
votes
3answers
841 views

Role based Database Schema

I am designing a database for a document management app for my office. I want to get the backend right so I don’t have issues in the future. Basically all users will be categorized into roles e.g, ...
1
vote
1answer
739 views

ORM Inheritance mapping or not, how to map shared and specific properties for a set of related, real world objects

When I was starting in OO programming, mostly Symfony and Doctrine ORM, I have been advised at least one time to apply inheritance mapping for a case as follows: For instance, a HR system which deals ...
1
vote
3answers
711 views

Organisation of complex business-logic (set of rules)

I have 20 entities and 50 user requests. And i have very complex business-logic (set of rules). How can i make my architecture so I'm not confused when adding new rules. Now if i add property "...
3
votes
2answers
113 views

Beste practice: ORM (in PHP, but general): Save changes to database directly or on request?

Imagine an ORM system, independent of language but let's assume PHP. Data is encapsulated in PHP objects and stored into and loaded from database. Let us have a theoretical object "Person" with ...
1
vote
1answer
326 views

Doubt about representing a Shopping Cart in Class Diagram/ER Database implicating ORM

I have to do a task which is reading a text, and create a Class diagram. One of the entities is a Shopping Cart. My doubt is how to represent a Shopping Cart in a class diagram, later on an E/R ...