Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [orm]

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

Filter by
Sorted by
Tagged with
12 votes
5 answers
7k views

Is it an anti-pattern to create ORM entities based on existing database schema?

I maintain a large legacy app working with SQL database. The app uses raw SQL queries to query the database. Together with app rewrite I plan to introduce ORM to work with the database. The simplest ...
user14967413's user avatar
2 votes
1 answer
148 views

How do I structure my functions (and classes?) which interact with my Database/ORM?

So I am working on my first project using SQLite and SQLModel as ORM. Creating and handling the first table in my database was easily structured: A function for each CRUD-Operation. But now I have ...
Jan's user avatar
  • 203
0 votes
3 answers
145 views

Should security and data validation be implemented within database or application?

I am building a simple web app where one set of users have varying admin privileges who can write to database and the other set can only view data. I am used to securing APIs with JWT or session ...
Hashir's user avatar
  • 1
0 votes
3 answers
470 views

Using orm events or database triggers

In orms, we can easily perform our desired operations in the save() method (for example, when a record is added in the likes table, the count column in the post table will increase.) This is great, ...
PersianMan's user avatar
1 vote
0 answers
45 views

Separating Typeorm Entities from Domain Entities [duplicate]

Is it a bad approach to add domain logic inside typeorm entities if following the domain model pattern to organize business logic. import { Entity, PrimaryGeneratedColumn, Column } from "typeorm&...
Maak's user avatar
  • 67
2 votes
2 answers
1k views

Why should I use an ORM like Entity Framework Core?

I have taken over the maintenance and development of a mature .NET Framework ASP.NET MVC application which uses an Entity Framework repository pattern. Several developers have worked on it before me ...
Ian's user avatar
  • 131
0 votes
1 answer
224 views

Approach for store multiple relationships POO objects in relational database

I'm developing a system in which a ClassA object can have multiple ClassB and ClassC objects. And for store these objects in a relational DB model I create the following tables: This is a simplified ...
Caeta's user avatar
  • 177
0 votes
0 answers
51 views

Database-driven application. Code pattern to establish relationships

I have an application that mostly is composed of forms that create, modify, read, and deletes tables and establish relationships. I use SQLAlchemy. If, for example, I need to create an invoice and ...
user avatar
2 votes
1 answer
2k views

How to organize ORM models and business logic

I have a Python application using SQLAlchemy. It uses around 15 database tables. For example, I have an image table that lists image files manipulated by the application. Most operations involving ...
Hey's user avatar
  • 159
-2 votes
1 answer
92 views

Entity objects with data external to the database

I'm looking for design patterns to model (java) objects that are partially stored in a database and partially stored some other external source. In my case the external data is a whole lot of files ...
Johannes Hahn's user avatar
3 votes
2 answers
841 views

Read-only view to reference other Aggregate Roots

In his book Implementing Domain-Driven Design Vaughn Vernon suggests to reference other aggregate roots only by identity and not by reference, like this: // Aggregate Root class Order( val ...
deamon's user avatar
  • 876
0 votes
1 answer
55 views

ORM patterns: entity properties that depend on collection loading

Given a couple of entities, Invoice and InvoiceRow, I want to calculate the total amount by summing up each row's amount. public class Invoice { [Key] public int? Id { get; set; } public ...
AgostinoX's user avatar
  • 841
2 votes
1 answer
269 views

Is it a good design to have separate Hibernate entities for general user info and user password digest?

I'm developing an app with a user management system. There is a database table named user with the following columns: | Column Name | Column Type | |-----------------|-------------| | userId ...
johnlinp's user avatar
  • 121
1 vote
1 answer
2k views

Bulk Update of DDD Aggregate Roots

In my applications users can perform actions on a few thousand aggregate root instances with a single click. The problem is that the UI is blocked for several seconds (~ 3) what feels too slow. So, I'...
deamon's user avatar
  • 876
-4 votes
1 answer
194 views

Alternatives to inheritance for polymorphic behavior for data in database?

I am thinking of designing a website where people can enter their aliases for games they played in the past and they can search for others around the same time period. FWIW I don't care if it exists ...
Vishaal Kalwani's user avatar
-2 votes
2 answers
110 views

Select from many-to-many in one query

A common issue I run into when building CRUD applications is how to retrieve many-to-many relationships from the database and put them into an object model. Say, for example, I have the following data ...
Omegastick's user avatar
-4 votes
1 answer
427 views

Express SQL Query As Abstract Object Model

Goal: write code to express SQL queries in C# that get converted to SQL at the data layer level and will be compatible with any common data layer / ORM such as Dapper or Entity Framework (EF). Edit: ...
Christian Findlay's user avatar
0 votes
1 answer
66 views

Mapping of time based models to database

Currently I'm developing a movie reservation system for diving into Spring Framework. I'm using Spring Data JPA for database modeling. I have several model classes but I am stuck with time-based logic ...
arkantos's user avatar
  • 111
0 votes
0 answers
584 views

DDD Value Objects and Entity Without ORM Mapping in PHP

First, as I know, Entity in DDD is almost same with Value Object except Entity has identity. Every article I have read say same thing that entity id has ORM mapping with any ORM tool. But I don’t want ...
Furkan's user avatar
  • 101
1 vote
2 answers
533 views

Should database model POJO contain *entities* or *ids* when having 1:M, M:N relationships?

Though this seems less like a software engineering problem, IMHO it is actually about programming paradigms, instead of specific "how to solve this bug" questions... Say we have article, author and ...
ch271828n's user avatar
  • 181
-2 votes
1 answer
628 views

Converting a table to an ORM schema

I'm trying to convert this table into an ORM schema: The solution given by the book is this one: It connects all the paramether to the Member one. This is my solution, which I think it's less ...
PorcoDioBastardo's user avatar
4 votes
2 answers
351 views

How to write dynamic (non ORM) repositories that can return only the necessary data without creating many methods or data-objecs?

We're currently developing a Spring application that uses jdbcTemplates for the repository. We have a lot of functions that only require specific combinations of columns in our database. It would be ...
Joe's user avatar
  • 405
1 vote
2 answers
1k views

Does references between entities of the same aggregate hurt the Aggregate Pattern from DDD?

Consider an application being implemented following Domain Driven Design. In the same aggregation, there are Car and Computer entities that should have a one to many relationship between them (Car ...
user avatar
0 votes
1 answer
130 views

Questions about Direct access to data source from Services

Background: I'm trying to separate my concerns in the application architecture the best possible way. In a nutshell: The requests are parsed and go to an Action Action decides which service(s) to ...
Vjolenz's user avatar
0 votes
0 answers
163 views

Need some design advice on my ORM for Immutable objects & ref passing

I'm adding Immutable objects support to my Micro ORM called "Symbiotic" In the case of a create, I need to pass back a newly created version of the value passed in because the object is immutable and ...
Eric Schneider's user avatar
1 vote
2 answers
173 views

How to keep track of db tables used in various apps [closed]

I have N applications using ORM, SQL-statements and stored procedures to access M tables from an MSSQL Server 2017. There are some shared tables that are used by various apps. Let's say I am forced to ...
exeC13's user avatar
  • 39
2 votes
2 answers
446 views

Query with a lot of fields and joins

I have to map a legacy database with tables that have a lot of fields and relations. For example (simplified code), @Entity @Table(name = "VISIT") public class VisitEntity { @Id private ...
javlacerda's user avatar
2 votes
2 answers
84 views

At what size array in Swift would you consider switching to CoreData?

I've developed a reading tracking app in Swift and for simplicity's sake I used arrays for my model. It stores some data about the books a user reads and a small image of the cover. I save them to ...
M. Chollar's user avatar
-1 votes
1 answer
399 views

DDD persistence through non-orm tools in java

So our domain model drove our database and ORMs worked for DDD implementations. Now the tables have been altered a lot and as a consequence ORM impedence is too much in our domain model to use ...
Dexters's user avatar
  • 135
1 vote
2 answers
866 views

Domain models vs entity models vs Hibernate lazy loading

In a new Java project I plan to use an extra layer above Hibernate entities. So there would be a CustomerEntity and CustomerDomain. The reason for that is that the CustomerDomain can contain extra ...
Vmxes's user avatar
  • 147
0 votes
1 answer
263 views

Combining web app and CLI to python package

I'm writing a program in Python that has two different entry points. There's a CLI that processes some data and needs to be installed to run hourly on a server, this populates a database. There's also ...
Nick Martin's user avatar
0 votes
0 answers
49 views

What layer should resolve pre-existing Hibernate entities?

Imagine an application that consumes an external data stream and creates objects of this type: @Entity public class Event { @OneToOne(cascade = CascadeType.ALL) private EventInfo info; @...
Alex R's user avatar
  • 109
2 votes
1 answer
4k 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 ...
Jakob Busk Sørensen's user avatar
4 votes
1 answer
2k 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. ...
EresDev's user avatar
  • 151
4 votes
1 answer
111 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 ...
user27886's user avatar
  • 151
18 votes
3 answers
9k 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. ...
MZawg's user avatar
  • 423
0 votes
1 answer
2k 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....
Jan Paolo Go's user avatar
1 vote
1 answer
170 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 ...
robodude666's user avatar
-1 votes
1 answer
229 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 ...
software_writer's user avatar
0 votes
1 answer
77 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 ...
RegretfulWasher's user avatar
1 vote
1 answer
263 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 ...
Jessica's user avatar
  • 349
0 votes
3 answers
2k 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 ...
w0051977's user avatar
  • 7,091
1 vote
2 answers
426 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&...
Konrad's user avatar
  • 1,559
3 votes
1 answer
2k 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 ...
mannok's user avatar
  • 189
0 votes
1 answer
71 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 ...
Green Mind's user avatar
1 vote
2 answers
188 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 ...
turnip's user avatar
  • 1,667
9 votes
2 answers
9k 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, ...
bielu000's user avatar
  • 277
34 votes
5 answers
33k 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 ...
Konrad's user avatar
  • 1,559
1 vote
0 answers
859 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 ...
lightning_missile's user avatar
2 votes
1 answer
2k 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 ...
mysubject's user avatar

1
2 3 4 5 6