12,039 questions
0
votes
0
answers
31
views
cant manage to make entity corresponding to entitygraph query
so i am using entity graph to make a dynamic query of a table, the query is being made correctly which is corresponding to my graph and subgraph attribute nodes but when i fetch it as the entity, the ...
0
votes
0
answers
20
views
How can I create a "managed type" for a Spring Data 3.4 @NativeQuery interface to access data with?
We have a very sparse DAG stored in a MySQL 8 table. I want to get all of the nodes leading into (and out of) a given node. The query can be written without too much trouble with the help of this ...
0
votes
1
answer
50
views
Enable Hibernate @Filter as default in Springboot for soft delete
I defined a Hibernate Filter to filter out the deleted records.
My wishlist:
The Filter should be enabled all the time as default.
Only in special cases when I need the deleted records, then I would ...
0
votes
1
answer
76
views
IDs are mismatched when calling Spring Boot REST API from Next.js client generated using OpenAPI/Swagger
I have a Spring Boot Data REST project with the following classes
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Product {
@Id
private String sku;
@OneToMany(...
2
votes
1
answer
162
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(...
-1
votes
1
answer
76
views
Spring Data JDBC inserts varchar into Postgres jsonb column even with custom PGobject converter
I’m trying to persist a JSON object into a PostgreSQL jsonb column using Spring Data JDBC (not JPA).
Even with a custom @WritingConverter that returns a PGobject of type jsonb, PostgreSQL errors out ...
1
vote
1
answer
121
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
@...
0
votes
1
answer
164
views
Spring Data JDBC - mapping a series of nested one-to-many relationships inside an aggregate
This is a request for clarification after watching a video about Spring Data JDBC.
I have an aggregate made of Book (aggregate root), BookCopy and BookCopyQualityControl. A Book has many BookCopy, and ...
0
votes
1
answer
71
views
undefined method error in eclipse in a project correctly building with maven
Eclipse gives me the following error:
The method delete(Sumti) is undefined for the type SumtiRepository DeleteBridiTest.java
The relevant parts of DeleteBridiTest.java:
public class DeleteBridiTest ...
1
vote
0
answers
67
views
Why does findByTypeNotIn in Redis OM Spring generate the same RediSearch query as findByTypeIn?
I’m using Redis OM Spring with a simple repository:
@Document(value = "Marker", indexName = "MarkerIdx")
data class RedisMarker(
//other indexed
@Indexed
...
2
votes
1
answer
68
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
0
answers
67
views
Sharing a common model between a transformer API and persistence layer API
I am working on a Java project where certain XML files are converted to POJOs and then saved to the database in Cassandra. The 2 projects have a common model which are identical in every way. Since ...
1
vote
1
answer
47
views
Why does Ignite allow SQL querying of a cache A (only) from a different cache B's Ignite Cache reference
I noticed that Ignite seems to allow SQL querying (with SqlFieldsQuery) of a cache say cache A from a different cache say cache B's IgniteCache reference.
I can understand join queries, but shouldn't ...
0
votes
1
answer
141
views
How do I serialize a Kotlin LocalDate or LocalDateTime to a BsonDateTime with Spring Data?
I am trying to serialize a model with a LocalDate into a BsonDateTime using Spring Data Mongo. This MongoDB guide for Kotlin usage says that, with the @Serializable and @Contextual annotations, ...
0
votes
1
answer
39
views
Aggregate and paginate over inner array with SpringData MongoDB
I need to paginate over documents contained in arrays of the root documents. For example, to view the first 10 orders with an open status across customers.
Customer structure
{
"_id": ...
0
votes
1
answer
65
views
Handling optional search parameters in Criteria API
Imagine I have optional search parameters that can be null.
Is there a more concise alternative for checking each of them explicitly before adding a jakarta.persistence.criteria.Predicate to some ...
-4
votes
1
answer
101
views
Referencing parameter attributes in JPQL
I get a nice DTO in my controller.
// UserController
@GetMapping
public ResponseEntity<List<UserResponseDto>> findUsers(@ParameterObject FindUserRequestDto userRequestDto,
...
-1
votes
1
answer
46
views
Fetching records matching multiple joined attributes
I need to return User records that:
Have an email matching email strictly and
Have a phone matching phone strictly
All of those are optional. That is, the request may contain only an email, for ...
2
votes
1
answer
88
views
@EntityGraph makes eager attributes lazy
I want to be able to eagerly fetch associated "to-many" entities. So I included a separate "eager" query method annotated with @EntityGraph.
@RepositoryDefinition(domainClass = ...
0
votes
0
answers
39
views
Tracking query triggering code in Hibernate
Suppose I see a seemingly redundant query in my log.
Hibernate: select pd1_0.user_id,pd1_0.id,pd1_0.phone from phone_data pd1_0 where pd1_0.user_id=?
spring.jpa.show-sql=true
How do I find out what ...
0
votes
1
answer
94
views
Spring/Hibernate native query, MySQL parameters not bound
I have the following query method for a native query in a Spring Boot application
@Query(value = """
SELECT a.*, ST_Distance_Sphere(a.coordinate, ST_GeomFromText('POINT(:lat ...
2
votes
1
answer
40
views
How to manage DB dialect in spring data jdbc named queries?
With Spring Data JDBC, named queries can be written in META-INF/jdbc-named-queries.properties.
Does Spring Data provide a mechanism to have multiple files? Ideally one for each SQL dialect, jdbc-named-...
2
votes
0
answers
42
views
Spring Data CassandraDriverTimeoutException
I'm getting sporadic timeout exceptions from the Cassandra driver in a Spring Boot project, in spite of having what I think are the appropriate yml configuration properties.
spring:
cassandra:
...
0
votes
0
answers
50
views
StaleObjectStateException/ObjectOptimisticLockingFailureException after upgrading from Spring Boot Starter Parent 3.3.x to 3.4.x
I am trying to upgrade from Spring Boot Starter Parent to the latest version which is 3.4.5 at the time. It seems that Spring Data is trying to double save the same object now leading to a ...
0
votes
1
answer
106
views
What could be the issue with this composite key and query setup in Spring Data JPA?
I'm working on a Spring Boot project using JPA and trying to query an entity that uses a composite primary key with @IdClass, but I can't get the repository method to work.
I've double-checked that:
...
0
votes
1
answer
64
views
Ignite performs very slow in Spring Boot benchmark
I am doing a performance comparison test for multiple select statements executed one after the other in a for loop. The application tries to fetch all people having a certain age from an Ignite cache ...
0
votes
1
answer
30
views
Database contains embedded objects, but MongoRepository returns empty List
@Document("scenarios")
public class Scenario {
@Id
private String id;
@Indexed(unique = true)
private String name;
private String description;
@JsonSerialize(using = ...
1
vote
0
answers
136
views
How to use RedisTemplate.execute(SessionCallback) without type issues?
Here's my basic example setup:
private final RedisTemplate<String, Object> redisTemplate;
public void save(Object thing, Instant expiresAt) {
redisTemplate.execute(new SessionCallback<...
2
votes
2
answers
131
views
Spring Data JPA: Persistent Context Unexpected Behavior
The CategoryRepository is defined like this:
public interface CategoryRepository extends JpaRepository<Category, Long>{
@Transactional
@Query("select c from Category c where name = :...
0
votes
0
answers
72
views
Test tries to connect localhost instead of using embedded mongodb by @DataMongoTest
I have spring app which uses mongoRepository. I want to have an integration to test my repository by using @DataMongoTest. For some reason my test tries to connect localhost for mongo and gets timeout....
0
votes
1
answer
73
views
Spring Data implementing custom repository with abstract class in the middle
I need to implement filtering to all entities' repositories.
The filtering follows the same scenario, differing only in Filter and Entity params.
So now I have my filter interface:
interface ...
0
votes
0
answers
32
views
Spring boot JPA manyToOne duplicate key already exists
I am trying to get a manyToOne unidirectional relationship working, but i cant seem to get it to work
@Entity
@Table(name = "comments")
@Data
@AllArgsConstructor
public class Comments {
@...
0
votes
1
answer
82
views
Select more aggregate roots in a single query using Spring Data R2DBC
I have an application in Spring Boot 3.4.x using Spring Data R2DBC.
Let's say I have two aggregate roots, Book and Author. I understand that from the reactive point of view, it is not possible to work ...
0
votes
0
answers
29
views
Spring Data Cassandra Custom Repository - No property 'save' found for type
I'm trying to create a custom Cassandra repository but I'm getting:
No property 'save' found for type 'BookEntity'
I've looked at the Spring Data docs and some of the other questions here in the ...
0
votes
1
answer
79
views
MongoDB Timeseries Query Not Using Index And Taking Excessively Long
I have a large timeseries collection filled with millions of documents called "Events" that have the following structure
{
"_id": {"$oid": "123456"},
"...
1
vote
1
answer
122
views
My Custom Repository returns a vavr Try. Why does Spring Data jdbc wrap it in another vavr.Try?
I'm using spring boot 3.4.3.
I am trying to figure out best practices on how to use Spring, and I want to be able to return errors as types instead of throwing exceptions. That is my premise. If it ...
0
votes
0
answers
47
views
Using `JdbcTemplate` with `@Table` Entities in Spring Data JDBC Without a Custom `RowMapper`
I use spring-data-jdbc and have mapped my DB tables with org.springframework.data.relational.core.mapping.Table.
I also have some custom queries with org.springframework.data.jdbc.repository.query....
0
votes
1
answer
72
views
Is there a way to create a @Repository that does not get associated with a specific type?
I want to create a Spring Data repository that is primarily there to collect complex queries both native and JPQL using @Query. But I want to avoid tying it to an entity since it doesn't need to be ...
0
votes
1
answer
87
views
One-to-Many relation in postgreSQL and how to test it
I have an issue where I have an object that takes some fields, and one of these fields is a List (0-2, so nullable) and need to save it in a database (PostgreSQL is what I use). Now I know that having ...
0
votes
0
answers
15
views
How to group Spring Data parameter logs
In dealing with an application that makes several Spring Data queries where I have enabled the query logging as well as the query parameters, I'm having trouble determining which parameter values are ...
0
votes
0
answers
61
views
Spring Framework DefaultResourceLoader behavior
I am using ByteBuddy to generate classes from the JPA Persistence Unit and Spring Data,
an older version already works with the persistence unit, spring data jpa and spring webmvc and, now my ...
-1
votes
1
answer
42
views
Spring boot hibernate GroupBy with dynamic filters
I have a problem which i dont know how to solve with JPA.
Im trying to create a fetchAll endpoint with filters, But the filters can be empty and then i want to fetch all. And for that i use a ...
1
vote
1
answer
1k
views
@TransactionalEventListener with @Transactional and propagations REQUIRES_NEW, NOT_SUPPORTED
I don't understand why this is needed now. I can't start my application because I have a service with @Transactional annotation and some methods with @TransactionalEventListener, and everything was ...
2
votes
0
answers
109
views
Force JOIN query for Spring Data JDBC
Is there any way or some kind of extension which will generate JOIN query for default Spring Data JDBC repositories?
For example:
public class Root {
private @Id Long id;
private String name;
...
0
votes
0
answers
124
views
SpringData r2dbc vs jpa when saving a list of entities with the same ids
In Jpa Spring Data when using saveAll for entities with the same ids - saveAll successfully saves all the enitities into the database. For example
public interface JpaRepository extends JpaRepository&...
2
votes
0
answers
148
views
Spring data jpa works incorrectly with nativeQuery with enum param with H2 and mariadb
I have an entity with enum field. When I use native query with param of enum type and @Enumerated(EnumType.STRING) annotation it works incorrectly. I use spring-boot-starter-parent 3.4.2. I try to ...
0
votes
0
answers
53
views
Query annotation with sort on a date cause exception
I use spring boot 3.4.2, spring data jpa and oracle
I have this query
@Query("""
select n from Notice n
join fetch n.noticeType nt
join n.deposit d
...
1
vote
1
answer
719
views
How to use projection with specification in spring data jpa with jpa fluent api
I am trying to use interface base projection with JPA named methods and add specification, I read github issue and there the mod indicated that as of spring data jpa 3 we can use projection and ...
1
vote
1
answer
80
views
Spring Data JDBC repository-like service without extending Repository<Entity, Id>
I am using Spring Data JDBC repositories which are defined through interfaces (which extend Repository<Entity, Id> and have their queries specified through @Query) for various entities and ...
0
votes
0
answers
48
views
How to combine output of criteriaBuilder.function in one Expression
I want to execute the below sql query
SELECT * FROM form_submission b where MATCH(business_name ,message) against('meet*' in boolean mode) != 0
My application is based on spring-boot , spring-data-...