Questions tagged [spring-data-jpa]
Spring Data - JPA is part of the Spring Data umbrella project which makes it easy to implement JPA based repositories
21,266
questions
0
votes
1
answer
27
views
@Query doesn't work if I select more than 1 column
I have a query like below that doesn't work.
It throws IndexOutOfBoundsException: Index: 0, Size: 0
(sorry I can't post the whole stacktrace as it is in my workstation (remote))
This started to be ...
0
votes
0
answers
15
views
Error executing DDL "alter table semantics_clusters drop constraint page_fk"
@Entity
@Table(name = "semantics_clusters", uniqueConstraints = {@UniqueConstraint(name = "unique_name",
columnNames = {"name"})})
@Builder
@Getter
@Setter
@...
1
vote
2
answers
52
views
Spring boot jpa entity table name from property file
We are working on a spring boot library to generate and validate OTP. It uses database to store the OTP.
We are using Spring Data JPA for Database operations, as it will be easy to handle multiple ...
2
votes
1
answer
34
views
Spring Pagination and count query
I'm developping a REST API managing Module objects. For the UI, I need pagination and the total number of pages.
I know when Spring uses Page<T> an additional count query is used (to get the ...
1
vote
1
answer
25
views
I'm Trying to create table "User" in DB with using spring data JPA. How can I do that? [duplicate]
why can't I create table in db - "user" using spring data JPA ?
@Entity
@Data
@NoArgsConstructor(access = AccessLevel.PRIVATE, force = true)
@RequiredArgsConstructor
@Table(name = "user&...
0
votes
1
answer
29
views
SPRING PetClinic: BatchError when trying to delete vets with foreign key to visits
I got an assignment to extend the SPRING petclinic application (forked from this repo: https://github.com/spring-petclinic/spring-petclinic-rest ). One assignment is to "Show all visits by a vet&...
1
vote
1
answer
26
views
Spring Data queryForStream: how can it run out of Heap Space?
I have a Spring Boot application that reads from a database table with potentially millions of rows and thus uses the queryForStream method from Spring Data. This is the code:
Stream<MyResultDto>...
0
votes
1
answer
35
views
How can I run this SQL statement with SpringBoot data JPA?
I'm trying to create a data filter using SpringBoot and PostgreSQL, I'm trying to run a query to get a customer by its name or id or account id in a searchBar, running into an issue when running a ...
0
votes
1
answer
32
views
How can I write a JPA query that includes join operation?
So I have a SQL query like this,
SELECT *
FROM USERS.NAMES UN
JOIN USERS.ADDRESS UA
ON ADDRESS_TYPE IN ('{user_supplied_value_1}', '{user_supplied_value_2}')
AND UN.USERS_ID = UA.USERS_ID
...
0
votes
0
answers
19
views
liquibase + Failed to load ApplicationContext
I'm developing a test for an application with many models some of them with relationships. Every time I try to run the test, it says "Failed to load ApplicationContext" error.
I have a ...
0
votes
0
answers
11
views
Error creating bean with name 'entityManagerFactory' defined in class path ... : Table [command_failure_notification]
When I compile my spring project, I got the following error.
Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/...
0
votes
1
answer
26
views
How to save an entity without an id in Spring Data JPA (hibernate)
consider an entity with just an id and text field:
@lombok.Data
class Entity {
@javax.persistence.Id
UUID id;
String name;
}
consider that the table definition is as follows:
create table ...
0
votes
0
answers
15
views
flyway migration failing for update sql statement with join
I created the update statement with joins in flywaydb with 8.x version. the update statement is below and the actual database is postgres 14.x. It is showing syntax error.
SQL Query :
update ss s set ...
0
votes
0
answers
10
views
Spring Controller with Nested Payload (JPArepository & MySQL)
I am pretty new to Springboot (2 weeks) and currently stuck at sending nested payload to controller and storing it in database. My payload structure looks like.
{
A: { some key value pair} -> ...
0
votes
1
answer
12
views
not able to fetch data from the db when
I am getting an error when trying to fetch data from the database (the data exists in the db). I am able to perform the action when there is no data in the db.
This is my entities:
@Table(name = "...
0
votes
0
answers
32
views
Liquibase is not taking the configurations from application.yml
I have a spring boot application. And I have configured liquibase to create tables. I have few issues though. The tables are not getting created inside the schema and in the location provided in ...
1
vote
0
answers
46
views
ClassCastException in JPA query
I am trying to migrate from spring-boot 2.6.6 to spring-boot 3.0.2. Although, i get some really weird error in the custom queries which used to work in the previous version.
For example, in the ...
0
votes
1
answer
36
views
JPA Criteria Tuple query fails with missing columns from join in group by clause (Spring Boot 2.7.8 and hibernate 5.6.14.Final)
I am trying to use the JPA Criteria API to filter the results and aggregate them using simple count, min, avg and max. I am using Spring Boot 2.7.8, so I am trying to use Interface-projections such ...
0
votes
0
answers
29
views
integrate spring security and spring MVC and and spring integration with each other
I am currently developing a web site for having control over IOT devices by spring.
The application is based on spring boot.
I have developed most of rest API s by extending from DataJpa.
Next step I ...
0
votes
0
answers
46
views
Enum values are not saved in the database(PostgreSql)
The issue is that the enum values are not being saved in the database, so whenever I register new user it returns user with 0 role size even though I have all the right configurations, so came to the ...
1
vote
0
answers
41
views
Spring Data Hibernate: How to use fetch type specified in entity for custom queries?
I'm working on a Spring Boot 3.x application with Spring Data and Hibernate 6.x. I've got an entity class that looks like this:
@Entity
public class User {
@Id
private UUID id = UUID....
0
votes
1
answer
29
views
How to associate nested object (exist in database) with parent object ManyToOne relationship?
I want to save Student object -which has no id- to database. However, Student object has several child objects - which have id -.
How can i save parent object in one time without getting child objects ...
-2
votes
0
answers
40
views
How can I use JPA saveAll batch insert/update if my repository class is using GenerationType.IDENTITY [duplicate]
JPA with spring data SaveAll using batch insert/update will only work for
ID with SequenceGenerator
property: spring.jpa.properties.hibernate.jdbc.batch_size
But is there any simple way that I can ...
0
votes
1
answer
24
views
Implement a regular interface in a spring data repository interface
I'm using a Repository that extends a spring data JpaRepository and would like to let it extend another interface.
Previously, my db repository looked like this:
interface ...
0
votes
0
answers
57
views
Spring Boot 3, Postgres and JPARepository method with Pageable as argument
Upgrading to Spring Boot 3, it turned out that JPARepository methods with Pageable as argument throw an Exception using postgres as a database. No problems with MariaDb. Also, running the query ...
0
votes
0
answers
15
views
JoinColumn with unique keys as combination of joinColumns and inverseJoinColumns
@JoinTable(name="policy_attributes",
joinColumns = @JoinColumn(name="policy_id"),
inverseJoinColumns = @JoinColumn(name="attribute_id"))
private Set<...
0
votes
1
answer
34
views
Column is of type uuid but expression is of type bytea when saving entity
I have a problem saving entity with UUID field. I create a new instance, call setMyGuid(UUID.fromString(guid)); and then call save method of my CrudRepository. But it produces SQL with column value '&...
0
votes
1
answer
53
views
Failed to instantiate com.zaxxer.hikari.HikariDataSource: Factory method 'dataSource'exception with message: Failed to determine suitable driver class
Iam trying to dockerizing springboot microservice application but getting below error while deploying. Below providing all configuration details. Please help to resolve by providing any hint.
Same ...
0
votes
0
answers
14
views
Permission denied Redshift Spring boot but works in SQL Client
I am trying to make a simple REST API to query a Redshift DB. I was granted access and can view the tables in DBeaver, but when I try to access it programmatically, I get:
Invalid operation: ...
-1
votes
1
answer
23
views
How to include redundant column to show in SELECT Query from second table instead from the main table in Spring Repository?
I have a query like this:
Query 1:
select *
from items item
This is bind to an entity in SpringJPA.
Now I have to select one more column from another table like below.
Query 2:
select item.*,is.id
...
0
votes
0
answers
27
views
Unable to build Hibernate SessionFactory "Name Cannot be null" when multiple datasource is used
I have used Namedjdbctemplate and Spring Jpa both in my project for which i have two Configuration class which is preparing the datasource for db2 database but when i run the project i am facing
Name ...
0
votes
0
answers
21
views
Postgres Refcursor type execution issue in springboot application
I have a stored procedure in postgres which returns the refcursor (rows from table). Im using the jdbcTemplate with callable statement for executing it (In Springboot application).
Added below stored ...
0
votes
1
answer
17
views
getting an error when trying to fetch data that is not in the db
I am getting this error when trying to fetch a data that does not exist in the database:
org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referential integrity
constraint violation: "...
0
votes
1
answer
49
views
How to show List in @OneToMany relation
I'm having an entity TechnicalStack and an entity Category, which an Category may have many TechnicalStack inside.
Here is my code:
@Entity
@Table(name = "technical_stack")
public class ...
0
votes
1
answer
8
views
Select phrases ordered by frequency
@Entity
@Table(name = "clusters", uniqueConstraints = {@UniqueConstraint(name = "unique_cluster_name",
columnNames = {"clusterName"})})
@Builder
@Getter
@Setter
@...
0
votes
2
answers
25
views
Not able to join 2 tables in spring data jpa
I am new to spring-data-jpa. I am working on a task management system.
I have 2 entities:
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long taskId;
private String ...
0
votes
2
answers
54
views
Azure spring boot JPA
Am using azure keyvault to store my db username , url & password. I am using
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-starter-...
0
votes
0
answers
26
views
nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Export identifier [meeting_window_meetings] encountered more than once
This is how my class looks like :
crm/model/meetingwindow/MeetingWindowMeeting.java
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "meeting_window_meetings")
...
0
votes
1
answer
62
views
Spring Data JPA how to avoid loading a column
I have two entities:
@Entity
@Table(name = "locations")
@Data
@NoArgsConstructor
@RequiredArgsConstructor
public class Location {
@Id
@Column(name = "location_id", ...
0
votes
0
answers
34
views
Convert from one DTO into another
public class ClusterDTO {
ClusterEntity cluster;
Integer used;
Integer unused;
Integer total;
}
public interface ClusterDTOaux {
// Used only to extract the data to be ...
0
votes
0
answers
18
views
How to development multi language application in spring?
I want to development multi language application. but I can't find detail information ve documents. How to get rows of current language data? When the user language changes, I want the data suitable ...
-1
votes
0
answers
29
views
What is the correct way to connect several companies to databases? [closed]
For example, I want to create a page that shows users from various companies. Is it correct to create different backends and for each one to connect to a database (one database per company) or should ...
-1
votes
2
answers
46
views
could not serialize; nested exception is org.hibernate.type.SerializationException: could not serialize
I have spend way too much find finding the root cause of the below error:
org.springframework.orm.jpa.JpaSystemException: could not serialize; nested exception is org.hibernate.type....
0
votes
1
answer
24
views
How to connect multiple database with testcontainers
I have a app using an utility library where classes are defined as
@Entity
@Table(name = "event" , catalog = "GE_events")
public class Event{
...
}
while the app domain classes ...
0
votes
1
answer
17
views
Unsatisfied dependencies for type X at injection point besides bean-discovery-mode set to "all"
I am running Jakarta EE 9 (Java JDK 17) project on Wildfly 27.0.1 Final that alsp uses Spring-data. I had a similar setup running on Java EE 8 (Java SDK 8) on Wildfly 20.0.1 Final running without ...
0
votes
1
answer
34
views
Cast LocaDateTime to Date in QueryDSL
Query DSL has castToNum() but is there anything to convert LocalDateTime(job_date_time) to Date ?
SELECT user_logon as logon, cast(job_date_time as date) as
dateTime,SUM(total_pages) as total
from ...
0
votes
0
answers
41
views
JPA Repository save not saving the list data in input sequence
I have a class called Drink with id, name, expirationDate. It is treated as a List under Order class.
I have an API call that saves an Order which has List.
Ex:
Drink : first drink, Drink: second ...
0
votes
0
answers
20
views
Inferred type 'S' for type parameter 'S' is not within its bound; should extend <Package>
when I want to create a jwt for my springboot application I get an error in the repository.save()
section using CrudrRepository when I want to registered my data to entity, I was told to extend my ...
2
votes
1
answer
45
views
Spring boot JPA filter data based on relation
I have 3 entities in my Project. Entity A (eA) has an One-to-Many relationship with Entity B (eB) and eB has an One-to-Many relationship with Entity C (eC). I have fetch = eager in all of them.
I want ...
0
votes
1
answer
51
views
Post request with springboot json format
I have a product table, I have a second option table. I cannot manage to create my options for the product at the same time as I create the product. I tried to create the options individually by ...