As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [spring-data]

Spring Data is an umbrella open source project which contains many subprojects that are specific to a given database. The projects are developed by working together with many of the companies and community that are behind these exciting technologies.

Filter by
Sorted by
Tagged with
0 votes
1 answer
17 views

Prevent Spring from dropping tables and instead drop the schema only

I'm using Postgres and Spring Boot JPA and would like specific application instances to cleanly spring.jpa.hibernate.ddl-auto: create-drop their respective schemas (each instance has its own ...
user462982's user avatar
  • 1,635
0 votes
1 answer
13 views

Spring Data is not scanning my MongoDb repositories, why?

I have a demo app showcasing various practices. It inserts data in a MySQL database AND in a MongoDb database. It used to show these lines in logs : Bootstrapping Spring Data JPA repositories in ...
Tristan's user avatar
  • 8,603
0 votes
0 answers
34 views

"Spring Data JPA - Exception: 'No Property Found for Type' with Inheritance Between Repository Interfaces"

I have two repository interfaces. One is more generic: @NoRepositoryBean public interface JpaGenericRepository<T> { List<T> find(Query<T> query); long count(Query<T> ...
gmn_1450's user avatar
  • 119
1 vote
0 answers
17 views

Spring Boot JPA Specification for Exists query

my table data looks like below, Employee Table EMP_ID EMP_VERSION EMP_STATUS EMP_NAME 123 1 ACTIVE Kathy 123 2 DRAFT Kathy 245 1 ...
Lolly's user avatar
  • 33.8k
0 votes
4 answers
46 views

Spring Boot/JPA - How i can delete a record from database with DeleteMapping?

my problem is that I want to delete a record from the database by id by selecting a button, but when I click the button to delete the corresponding record with the parameter id I get this error: > ...
Djorkaeff's user avatar
0 votes
1 answer
41 views

Spring Boot - dynamically choose datasource with different SQL flavours based on a feature toggle

I have a number of existing Spring Boot applications that use either Crud or Jpa repositories. I'm working on migrating them from SQL Server to Postgres. I'd like to be able to dynamically swap the ...
sumek's user avatar
  • 26.6k
0 votes
0 answers
19 views

Use SpEL in JpaRepository Query Hint

I am using spring-data-jpa 2.7.8 and I want to use a parameter in application.yml of a spring boot application to set the HINT_FETCH_SIZE like the following example, Is it possible to use SpEL in the ...
Wafa's user avatar
  • 146
0 votes
0 answers
27 views

Build single object for save with JPA instead of multiple saves and updates

I have a Spring Boot rest API where I use JPA to write the request & response messages for several dependency applications to a Postgresql database: Entities are structured as follows: @Builder @...
runnerpaul's user avatar
  • 5,618
0 votes
3 answers
68 views

Spring Data JPA - Exception thrown when using DeleteById with a non existing id

I am using a spring data JPA with a Postgresql db. I have an elementary table, a primary key (varchar) and some attributes. I have a repository and a service using this repository. I am facing an ...
Tokoro-San's user avatar
0 votes
1 answer
10 views

Ignore property when persisting to ES, don't ignore when persisting to DB

Using spring-data(-elasticsearch), I want to persist a property to a PSQL DB but not to Elasticsearch, i.e. the opposite to this question: Spring data: How to ignore field for relational database but ...
Wang Tang's user avatar
  • 540
0 votes
1 answer
25 views

Spring JPA how to persist a nested object

Context: Lets say I have 3 entities. Entity A (Portfolio) which contains a list of Entity B (Categories) which contains a list of Entity C (CategoryItems) Let's say I already have a Portfolio with ...
TrollBearPig's user avatar
0 votes
1 answer
34 views

Spring boot - Use external jar to manage database connection and it's required dependencies

I have a main spring boot application that connects to a mongodb to perform certain actions. It's main class: @EnableMongoRepositories(repositoryBaseClass = CustomMongoRepositoryImpl.class) @...
thanili's user avatar
  • 755
0 votes
0 answers
22 views

How to handle constraint violation when using Spring Data JPA with Oracle Identity column and a different column as primary key?

Spring JPA with Oracle DB : Our database schema has a table with an Oracle Identity column (id) and another column as a primary key uuid. The problem I am running into is when using save operation on ...
VPN236's user avatar
  • 13
0 votes
1 answer
25 views

Spring Data DynamoDB NoSuchMethodException on everything except save

The service is using a DynamoDB with Spring Data. Database access, object mapping etc. all work without errors, I can save objects in the database as expected. My problem is that no method except the ...
Juliette's user avatar
  • 916
0 votes
0 answers
18 views

In spring data cassandra updating udf field via update.query results in error

I'm trying to update cassandra nested field (udt) using spring data query API: cql.update(Query.query( Criteria.where(Attachment.Key.MESSAGE_ID).is(5), Criteria.where(...
Pavel Moukhataev's user avatar
0 votes
0 answers
18 views

Spring Data and Cassandra @Query with variable table names

I have a Spring Cassandra entity class as follows: @Builder @Table(value = "#{@environment.getProperty('my.table.name')}") public class UserEntity { @PrimaryKeyColumn(name = "id",...
mang4521's user avatar
  • 720
0 votes
3 answers
81 views

Spring JpaRepository findAll method execution returns empty/no data silently

In my production code I was using spring JPARepository.findAll method, we suspect that for one of its execution it returned an empty list (though db table is having the data )instead of throwing an ...
Vaibhav's user avatar
  • 159
-1 votes
1 answer
39 views

when I added spring-security (basic Auth) then the getMpping works but the postMaping show 403 Forbidden

@RestController public class UserController { @Autowired UserService userService; @PostMapping("/adduser") public String addUser(@RequestBody Users user){ return userService.addUser(...
Numaira Nawaz's user avatar
0 votes
1 answer
27 views

Cycles in custom JPA repository

I recently update my Spring Boot from 2.3.4 to 2.7.11 and my tests (but not the application) seem to have stopped working. The error I got was The dependencies of some of the beans in the ...
Archimedes Trajano's user avatar
0 votes
1 answer
17 views

How can I save only unique models in Spring Data?

I try to fix exception: Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint when save model with help repository.save(model). How will I fix this ...
Вадим Липаков's user avatar
0 votes
1 answer
32 views

Spring Boot - Is there a way to create folders with date parameter names?

I would like to know if there is any method or function in Spring Boot that allows you to create folders with names of year, month and day, and that they are subsequently created with the current ...
Djorkaeff's user avatar
0 votes
1 answer
34 views

Set<Enum> attribute in JPQL query returns exception at runtime

I migrated an application from Spring Boot 2 to Spring Boot 3. It worked before, but now I have a problem. Given an entity with this attribute: @JsonIgnore @ElementCollection(fetch = EAGER) ...
Jasper's user avatar
  • 469
0 votes
1 answer
27 views

Missing required property 'Builder.<variant kind>'

public void getMaxMinPrice(String category, String subcategory) { var nativeQueryBuilder = new NativeQueryBuilder(); nativeQueryBuilder.withQuery(queryBuilder -> ...
Binary's user avatar
  • 27
0 votes
0 answers
22 views

Spring tiles Error : Cannot render an attribute that is not a string, toString returns: null

I am making a spring mvc project and getting this error. Have checked everything multiple times but getting through it. Please have a look at my code and help me identify with where and what I am ...
Ananya's user avatar
  • 23
1 vote
0 answers
21 views

SpringDataCouchbase - Not able to save map with collection as value

Tried to save Person entity with below attributes in couch base, but not able to save getting error, see below error log. Note: Issue in Spring boot 3.X onwards, Spring-data -couch 5.X onwards not ...
dhananjay dumbre's user avatar
2 votes
0 answers
33 views

Eclipselink to Hibernate migration: em.persist fails in hibernate when not null is set in DB

We are migrating our application from eclipselink to hibernate. In our legacy code we are persisting the object first, then setting the values. This used to work in eclipselink but fails in hibernate ...
Hasn A's user avatar
  • 73
0 votes
0 answers
23 views

SpringBoot 2.7.4: Initialize Datasource from active profile properties

We are initializing datasource as per the active profile as below and we are providing the CONFIG_DIR as environment variable during the startup as SET CONFIG=-DCONFIG_DIR=src\main\resources, am ...
OTUser's user avatar
  • 3,788
1 vote
2 answers
57 views

Field orderRepository in app.service.OrderService required a bean named 'entityManagerFactory' that could not be found

I am trying to create REST API Service with Spring. I have following structure and classes app\ ├── controller\ │   └── OrderController.java\ ├── dto\ │   └── OrderDto.java\ ├── model\ │   └── Order....
PrintScreenSys's user avatar
0 votes
0 answers
22 views

Jpa, operations with Entity and String primary key

I have this Entity: @Entity @Getter @Setter @Table(name="PEOPLE") public class People implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(...
Alex's user avatar
  • 111
0 votes
1 answer
39 views

Deleting or adding child entities to parent with Spring Boot Hibernate JPA

I have the following entities: class Question { String question; QuestionType type; List<QuestionOption> options; } class QuestionOption { String option; Question question; }...
mok_1's user avatar
  • 51
0 votes
0 answers
28 views

How to get values which do not exist in databse by comparing with the list values in spring boot

I am having a spring boot application which reads values from the Microsoft access file and then checks if the value exists in the database then gets updated or else inserted as the new record however ...
Janeth Jackson's user avatar
0 votes
0 answers
43 views

how to make a relationship between tables in Java Spring

I have a request SQL and can't implement in Java spring` SELECT DISTINCT mo.MName AS 'Boss', tdg.DName AS 'Name group', it.IName AS 'Name item', tpis.mDesc AS 'Item ', ...
Артур Захаров's user avatar
0 votes
2 answers
32 views

why I getting this error on write query in JPA repository in spring-boot?

package com.example.demo.Repository; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org....
Dineshkumar T's user avatar
0 votes
2 answers
44 views

Why are all of my tables being deleted when I shut down my Spring application?

I'm running a Spring Boot application on an EC2 instance. It seems to be connecting to the database just fine. However, when I shut it down (Ctrl+C), it deletes all of the tables in the database ...
Juan David's user avatar
4 votes
2 answers
367 views

Parameter of constructor required a bean of type that could not be found?

I have the following Spring Repository: import com.azure.spring.data.cosmos.repository.CosmosRepository; import org.springframework.stereotype.Repository; @Repository public interface ...
java12399900's user avatar
  • 1,633
0 votes
1 answer
21 views

Spring Data MongoDB array match

We are storing objectIds in array in a document. { "members": [ ObjectId("a"), ObjectId("b"), ObjectId("c") ] } (storing members' ID here) Now we get list of ...
navaltiger's user avatar
0 votes
0 answers
11 views

SpecificationExecutor.delete does not delete related entities with Cascade.ALL

I have following entities. @Entity public class Demand { @Id private String id; @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "demand", orphanRemoval ...
bilak's user avatar
  • 4,346
0 votes
0 answers
25 views

Is there any inbuilt method for UPSERT in spring JPA?

Is there any inbuilt method for UPSERT in Spring JPA ? Not the save() method which internally fired 2 query, 1. select and based on first query value it done insert or update. My requirement is any ...
Sk Monjurul Haque's user avatar
0 votes
0 answers
15 views

Spring Data MongoDB - Randomly select documents but in order of an enum

I want my query to randomly select 3 entries, but it should always select all entries with status "NEW" first, only if there are no entries in status “NEW” anymore it then should select ...
inconnu's user avatar
  • 611
1 vote
1 answer
20 views

Couchbase spring data with Transactional service

I am utilizing Spring Data Couchbase Starter to handle my Couchbase operations, and I need to implement transactions. However, whenever my event document is created by the transactional service, I ...
Chakib Arrama's user avatar
-1 votes
1 answer
49 views

When using the @ManyToOne and @OneToMany annotations, a stackoverflow exception is thrown

It seems like all the anotations for Hibernate are above variables in classes, but for what day I can't get rid of stackoverflow. I also use spring-data. Here's what the exception is: Root Cause java....
VadiMayer's user avatar
1 vote
3 answers
76 views

two tables got created in mysql with names blog and blog_seq through spring boot entity annotations

I am new in Spring Boot and such things, this is the first project I was trying to explore and was following a lecture for project creation, I made an entity class with @Entity and @Table annotations, ...
Prafull Jain's user avatar
0 votes
1 answer
77 views

SPR-16876 TransactionSynchronizationManager not returning correct values in implementation of AbstractRoutingDataSource

I am following this link https://vladmihalcea.com/read-write-read-only-transaction-routing-spring/ to set up the database master and replica instance in my spring boot app. The only difference is I am ...
Harsh Kanakhara's user avatar
1 vote
1 answer
25 views

Spring - Is there a way to display the id of a record after being registered with Thymeleaf?

In my project I want to show the id of the record in the view with Thymeleaf after it has been inserted successfully. Is there any way to get that result? Entity: @Entity @Table(name = "users&...
Djorkaeff's user avatar
0 votes
1 answer
45 views

Implementing horizontal sharding in Spring Boot project

I have a project which uses Spring Boot with Spring Data JPA to store data in a MySQL instance. Now my data is growing at a rapid rate. I searched and found some text regarding horizontal sharding of ...
dead programmer's user avatar
1 vote
3 answers
108 views

Spring Data/JPA - How can I check if a record already exists by name?

I have a question with Spring Data/JPA, I would like to know if there is any way to check if a name is already registered in the database with some function in the Repository with parameters. I have ...
Djorkaeff's user avatar
1 vote
1 answer
173 views

How to check if record exists before insert - Spring JPA [duplicate]

In the project that I am doing, I want to check if a record with the same data already exists in a specific field in the database, if it already exists then do not insert, if it does not exist that ...
Djorkaeff's user avatar
0 votes
1 answer
28 views

Deleting large volume of data at once in spring boot in fraction of a second

How can I delete large amount of data more than 10 million records in fraction of a second in spring boot project, the code I'm having right now takes more than 1 minute and 30s to delete these ...
Janeth Jackson's user avatar
1 vote
0 answers
28 views

Why isn't Spring Data Rest compatible with Spring's Feign on query parameter list?

Using @FeignClient to pass a collection via: @GetMapping("/api/cars/search/findCarsByIdIn") CollectionModel<Cars> getCars( @RequestParam("carIds") ...
James's user avatar
  • 2,981
0 votes
0 answers
39 views

How to share database connection between legacy web application and spring

I have a legacy web application and plan to migrate it slowly to spring. One of the first steps is to migrate a small part of the applications persistence layer to spring data with JPA, while also not ...
Jan's user avatar
  • 27

1
2 3 4 5
236