23,331 questions
2
votes
0
answers
22
views
How to force Spring Data JPA / Hibernate to replace rows on unique index conflict?
How can I force JPA to replace rows on conflict with a unique key without writing/maintaining an UPSERT SQL statement in the @Entity? My @Entity has many, many member variables and I don't want to ...
0
votes
0
answers
65
views
Spring Data JPA @Modifying DELETE query not working - old tokens remain in database
Problem Summary
I'm trying to delete old email verification tokens before creating new ones in my Spring Boot application. The SQL DELETE query works perfectly when executed directly in the database, ...
0
votes
0
answers
17
views
Why does Hibernate issue multiple SELECTs when saving entities with a composite primary key?
I'm working with Spring Data JPA and Hibernate, and I have an entity that uses a composite primary key via @EmbeddedId. Here’s the structure:
@Embeddable
public class CurrencyId {
private String ...
1
vote
1
answer
88
views
Asserting against DB state in Spring Boot integration test
How do I check the DB state in an integration test? Is injecting a JdbcTemplate the only option?
For example, you test a PATCH that, if successful, should update certain table cells.
I can't use a ...
1
vote
1
answer
41
views
Eager fetching doesn't work Spring Data Specification
This:
@Override
public List<UserResponseDto> find(FindUserRequestDto userRequestDto, Pageable pageable) {
Specification<User> specification = buildSpecification(...
1
vote
2
answers
94
views
Spring Boot JPA: delete() returns 204 but record is not deleted from database
As in the title - the delete method does not remove the record from the database, but the controller returns code 204, which means that the request was processed correctly.
FlashcardSet service:
@...
0
votes
0
answers
11
views
How to enable Javers for BaseJpaRepository
I liked to use Javers with BaseJpaRepository found in hypersistence-utils. But I am having trouble trying to figure out how to replace the JaversSpringDataJpaAuditableRepositoryAspect with a custom ...
0
votes
1
answer
25
views
Creating methods for each @NamedNativeQuery in a list of @NamedNativeQueries
I am working with some older code that has a fairly large catalog of existing @NamedNativeQueries in a JPA repository:
@Repository
@NamedNativeQueries({
@NamedNativeQuery(name = "query1",...
0
votes
0
answers
42
views
See actual executed SQL string in logs [duplicate]
Is there a way to see an actual SQL being executed?
I'm aware of this:
logging:
level:
org.hibernate.orm.jdbc.bind: trace
spring:
jpa:
show-sql: true
properties:
hibernate:
...
0
votes
0
answers
54
views
Spring JPA / Hibernate performance loading for Nested Collections
For sake of simplicity, consider the following entities and do assume that they are declared correctly as
Here are my entities
class EntityA {
private String id;
@OneToMany
List<...
0
votes
1
answer
45
views
Set alias manually for JPA Criteria API select
I have a large codebase built around the Criteria API in my project, so unfortunately switching to another approach (like rewriting with raw native SQL strings or adopting something like jOOQ) isn't ...
0
votes
0
answers
25
views
inheritance table class sets wrong entity
When retrieving an entity, hibernate retrieves a foreign object with id x of type A. But also in the same query it retrieves an object with id x (same value as for type A) but for type B.
Then an ...
0
votes
0
answers
34
views
Mapping an array of strings in an Olingo entity
I am developing an OData application using SAP Olingo V4 version 2.3.1. Previously, I was using version 0.3.6, which supported this functionality.
Currently, I'm facing an issue with mapping a comma-...
0
votes
1
answer
33
views
Second-level Hibernate cache doesn't prevent query for @OneToOne relation
I enabled Hibernate's second-level cache.
# logging
spring.jpa.show-sql=true
#caching
# ehcache.xml is not explicitly defined
spring.jpa.properties.hibernate.cache.use_second_level_cache=true
spring....
0
votes
0
answers
43
views
How to register a CustomConstraintValidator?
I have a problem. Hibernate constraints have been created in a library developed by us and made known with the resources/META-INF/validation.xml. These validations work wonderfully. They are also ...