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
-2 votes
0 answers
12 views

How to access PostgreSQL in Next.js? [closed]

Im a Python Web Developer, with Django. In Django I do a file of settings to describe the Data Base, as bellow. settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends....
user avatar
0 votes
2 answers
105 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 ...
user avatar
  • 109
0 votes
1 answer
64 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 ...
user avatar
  • 177
0 votes
0 answers
47 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
1 vote
1 answer
578 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 ...
user avatar
  • 149
-2 votes
1 answer
45 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 ...
user avatar
2 votes
2 answers
212 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 ...
user avatar
  • 806
0 votes
1 answer
51 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 ...
user avatar
  • 831
2 votes
1 answer
133 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 ...
user avatar
  • 121
1 vote
1 answer
591 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'...
user avatar
  • 806
-4 votes
1 answer
106 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 ...
user avatar
-2 votes
2 answers
99 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 ...
user avatar
-4 votes
1 answer
267 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: ...
user avatar
0 votes
1 answer
60 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 ...
user avatar
  • 111
0 votes
0 answers
291 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 ...
user avatar
  • 101
1 vote
2 answers
179 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 ...
user avatar
  • 181
-2 votes
1 answer
136 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 ...
user avatar
4 votes
2 answers
208 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 ...
user avatar
  • 393
1 vote
2 answers
665 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
  • 121
0 votes
1 answer
89 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 ...
user avatar
0 votes
0 answers
118 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 ...
user avatar
1 vote
2 answers
126 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 ...
user avatar
  • 39
2 votes
2 answers
278 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 ...
user avatar
2 votes
1 answer
57 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 ...
user avatar
-1 votes
1 answer
263 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 ...
user avatar
  • 135
1 vote
2 answers
641 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 ...
user avatar
  • 147
0 votes
1 answer
138 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 ...
user avatar
0 votes
0 answers
46 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; @...
user avatar
  • 109
1 vote
1 answer
3k 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 ...
user avatar
2 votes
1 answer
1k 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. ...
user avatar
  • 131
4 votes
1 answer
101 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 ...
user avatar
  • 153
17 votes
3 answers
6k 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. ...
user avatar
  • 403
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....
user avatar
1 vote
1 answer
86 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 ...
user avatar
-1 votes
1 answer
198 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 ...
user avatar
0 votes
1 answer
72 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 ...
user avatar
1 vote
1 answer
156 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 ...
user avatar
  • 329
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 ...
user avatar
  • 6,855
1 vote
2 answers
323 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&...
user avatar
  • 1,421
2 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 ...
user avatar
  • 179
0 votes
1 answer
65 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 ...
user avatar
1 vote
2 answers
161 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 ...
user avatar
  • 1,627
8 votes
2 answers
7k 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, ...
user avatar
  • 267
33 votes
5 answers
28k 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 ...
user avatar
  • 1,421
1 vote
0 answers
781 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 ...
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 ...
user avatar
1 vote
4 answers
151 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 ...
user avatar
1 vote
1 answer
3k 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 ...
user avatar
1 vote
1 answer
286 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 ...
user avatar
0 votes
2 answers
92 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 ...
user avatar
  • 1,537

1
2 3 4 5 6