23,356 questions
0
votes
0
answers
22
views
How to manage DTO proliferation for different API operations
I'm having trouble managing DTOs.
I'm working as follows: I have a reusable DTO called PhoneResponseDTO that is used in both findAll and findByID. Then I created a DTO for each operation like Created, ...
0
votes
0
answers
62
views
Spring Boot 2.7.x JPA @ManyToOne join returns empty list on GET, but works on POST
In a Spring Boot 2.7.x application with Hibernate/JPA, there are two tables:
tickets
complaint_id (PK, VARCHAR(255))
attachment
complaint_id (FK, VARCHAR(255))
other fields: id, file_name, ...
1
vote
0
answers
54
views
Hibernate Dirty Checking
I'm using Spring Data JPA with an entity that contains a Map<String, String> field.
The map is stored in the database as a TEXT column (JSON string). JPA automatically stores the map as a ...
1
vote
1
answer
66
views
Why is Spring attempting to use a read-only transaction when I explicitly requested a new write transaction?
I have a service method that performs the following operations in sequence:
Calls a read method annotated with a custom read-only transaction annotation (equivalent to @Transactional(readOnly = true))...
-3
votes
0
answers
84
views
JPA/Hibernate EntityGraph with Specification and Pagination not loading all related entities correctly
JPA/Hibernate EntityGraph with Specification and Pagination not loading all related entities correctly
I'm working on a JHipster-generated application and need to create APIs that load entities from ...
2
votes
3
answers
192
views
JPA recursive hierarchy read - StackOverflowError with FetchType.EAGER but LazyInitializationException with FetchType.LAZY
I'm working with these entities:
UserEntity:
@Entity
@Table (name = "users", uniqueConstraints = @UniqueConstraint(columnNames={"name"}))
public class UserEntity {
@Id
@...
Best practices
0
votes
7
replies
187
views
Best way to write an Oracle Procedure using Spring Data Jpa
I am new to JPA and learning it. Now I have an Oracle procedure in system, which now needs to be made DB Agnostic, that can run on Postgres. For that I want to write the same functionality of ...
2
votes
1
answer
152
views
How does Spring JPA “instantiate” the interfaces that extends repositories?
I'm delving into Java concepts such as dynamic proxies, reflection, etc. That's why I'm trying to implement some Spring features. Anyway...
I created the dynamic proxy:
@Override
public Object invoke(...
0
votes
1
answer
148
views
How to update a single field of an entity using PUT in Spring Boot?
I know how to use the HTTP PUT method to update an entire entity, but how to update a single field for an example?
I gonna need a lot of if's?
My method for updating the data in a Service:
public ...
1
vote
0
answers
30
views
Spring EntityManager persist vs merge for manual cascading one to many relationship [duplicate]
I have Post and Comment entities with one to many relationship.
@Entity
public class Post{
@Id
private Integer id;
@OneToMany(mappedBy ="post")
private Set<Comment&...
1
vote
2
answers
244
views
How to prevent N+1 queries in Spring
Could you please help me with how to avoid N+1 queries in Spring?
For example, I have the following two entities:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name="CourseID")
private ...
1
vote
1
answer
111
views
@LastModifiedDate is not updated with @ManyToMany relation
In Spring Boot I have an entity:
@Entity
@Table(name = "Product")
@EntityListeners(AuditingEntityListener.class)
public class Product extends BaseEntity {
...
@NotNull
@...
2
votes
0
answers
83
views
Hibernate @TenantId not applied to update/delete statements in discriminator-based multitenancy
I’m experimenting with Spring Data and Hibernate to implement multi-tenancy in an existing app using a discriminator column with @TenantId on the entities. I have seen that hibernate includes tenant ...
2
votes
1
answer
265
views
Make sure the consumer code uses @Transactional or any other way of declaring a (read-only) transaction] with root cause
I am trying to learn how to call stored procedure from springboot data jpa repository and returns a cursor from stored procedure. While I am implementing I am getting error like org.springframework....
0
votes
1
answer
58
views
Spring boot (Java) ManyToMany 415 error when sending POST
I have the most basic ManyToMany example, Project and Employee.
With a PUT request, I will project to employee and within the same function employee to project.
public Employee assignProjectToEmployee(...
2
votes
0
answers
110
views
How to reuse Specification<T> inside another Specification<F> with subquery?
I’m struggling with reusing a Specification<T> inside another one.
Entities:
Group has a list of StudentGroupInfo.
I already have a Specification<Group> that can filter Group by various ...
1
vote
1
answer
236
views
column is of type date but expression is of type bytea
I want to implement a custom column handler in Hibernate/Spring Boot app. I tries this:
Entity:
@Entity
@Table(name = "single_user")
@Getter
@Setter
public class SingleUser {
@Id
@...
2
votes
1
answer
60
views
Not able to reset sequence for the primary key of an entity
I'm implementing some tests for REST endpoints that manipulate a database (in test context, I use an H2 database) via spring data JPA, and I would like to have all the tables clean (no data in it, and ...
1
vote
1
answer
89
views
How to ensure rollback consistency and scalability when inserting into multiple SQL Server tables using JPA and JDBC in Spring Boot?
I'm working on a system where I need to store processed data across approximately 30 tables in a SQL Server database. For frequently used tables, I'm using JPA, while the majority of the insertions ...
0
votes
0
answers
58
views
A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: ProcedureStep.subSteps
My Java code is throwing the following error:
"A collection with cascade='all-delete-orphan' was no longer referenced by the owning entity instance: br.com.unika.pathdetail.entity.ProcedureStep....
0
votes
0
answers
32
views
jHipster jakarta.validation.ConstraintViolationException during integration tests
I am trying to get the integration tests of my app running (the app itself seems to be working). The issue seems to be related to how the ID column of a table is defined (I suspect that auto_increment ...
0
votes
0
answers
72
views
unable to access h2 console with spring boot 3 app (along with spring cloud gateway)
I have a requirement to create routing to different endpoints using gateway (ended up using spring cloud gateway [reactive stack]).
Upon setting up Spring Boot 3 project with dependencies, when added ...
0
votes
0
answers
87
views
Livereload (HotSwapAgent) not working with Spring Boot > 3.5.0, JPA, and Vaadin 24
Spring Boot > 3.5.0 + Spring Data JPA + HotSwapAgent + Vaadin causes injection error
I’ve tried multiple project setups using Vaadin Start, Spring Initializr, and various GitHub example ...
0
votes
1
answer
51
views
Delete then create entity using Spring JPA with Hibernate and @Transactional violates unique key constraints
Setup: SpringBoot application using SpringJPA with Hibernate
I have two entities: A and B. Set is a child of A.
I want to remove a B and create another one in a characteristic which would hit a unique ...
1
vote
1
answer
88
views
Obtain next sequence value for a Spring JPA Entity from the allocated IDs cached in Entity Manager?
I have an unusual situation which requires that I obtain unique identifiers from an Oracle sequence without actually saving a row to the table which relies on the sequence.
My entity:
@Table(name = '...