Questions tagged [hibernate]
An object-relational mapping (ORM) framework for the Java programming language.
85 questions
0
votes
3
answers
138
views
Optimizing writes over the same entity in relational DB
I am developing a micro service that saves votes to a relational database. I have a use case with an entity that represents an aggregation of votes. I receive events from voters saying that they vote ...
0
votes
1
answer
2k
views
JPA/Hibernate/Spring - What if M side of @OneToMany is not relevant for business logic?
I am writing a Spring Boot REST API using JPA, so I have my application layers consisting of
controllers
services
repositories
entities
models for request, response, DTOs
This question is mainly ...
3
votes
2
answers
427
views
What to do when putting logic into the database seems to be the only option?
I am currently working on an application that models a complex business process that consists of many steps, each having a 1:n relationship with subsequent steps. The software is written Java using ...
4
votes
3
answers
10k
views
Best practices for retrieving data scattered over multiple tables
In the company I work with, we have a 3-layer architecture in our micro-services and the flow is like this:
Repository/DAO (entity) => Service (entity) => Controller (dto)
At the Controller ...
2
votes
1
answer
323
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 ...
3
votes
1
answer
6k
views
Best way to handle lazy models with mapstruct and spring transactional scope
In a typical Java Spring Web APP:
we have the following layers:
Model [DB Models]
Repositories [where you have queries to DB]
Services [Business service where you have the @Transactional annotation]
...
0
votes
0
answers
870
views
What's a valid use case of JPA annotation @Transient?
I'm new to JPA and Hibernate. I just saw an annotation called @Transient, which can mark a field to be non-persistent in the database. However, for the sake of "separation of concerns" ...
0
votes
1
answer
213
views
Implementing a user ID system like Discords for a web app using Java Spring, JPA, Hibernate and MySQL
I’m trying to create a web application with a forum and user profile along with other functions. However I’m thinking about how I might implement an ID for each user. The best way I’ve seen other ...
0
votes
1
answer
7k
views
Best practice for references in DTOs and entities in Spring
Given the following architecture and frameworks:
Spring Boot Application with Spring Data JPA (Hibernate is used as OR mapper); layered architecture as followed.
REST layer
Service layer
Persistence ...
2
votes
1
answer
543
views
How to correctly translate UML Association, Aggregation and Composition to a Hibernate mapping?
There is a number of questions about the differences between UML Association, Aggregation and Composition out there and many many answers, some practical and some phylosofical. Here I'm asking we talk ...
0
votes
1
answer
2k
views
Decouple business logic from DTO
I've to implement some Backend Webservices, which provide a given, final JSON structure, which is allready in use on the FrontEnd side.
This structure doesn't match the database structure, so I have ...
0
votes
1
answer
1k
views
Mapping bidirectional 'toMany' relation from DTO to entity
The application that I am working on has numerous ...toMany relations, e.i. class Model can have several parameters. In Unidirectional world, it is simple to manage a collection. I can clean the ...
-3
votes
1
answer
2k
views
What do you think about DTOs in Spring Data JPA project?
First of all, I am not a junior programmer. I'm just looking for best-practice.
How do you use entities and DTOs into your Spring Data JPA projects?
Assume there is our layers:
Repositories (as ...
0
votes
1
answer
5k
views
In a Spring Boot Project, would you use interfaces for entities or not?
I am currently on the decision, whether to use interfaces throughout my whole spring project or not. I scouted some open source projects and saw, that many big projects are handling that quite ...
0
votes
3
answers
14k
views
Jpa Repository save inside a for loop
I have this requirement:
Csv Upload (using opencsv)
Should display if the record is inserted (if it doesn't exist in the db) or updated (if it exists).
Eg.: 5 records inserted 2 records updated.
...