320 questions
0
votes
1
answer
24
views
Row was updated or deleted by another transaction Spring Boot
hey im new to spring boot and i am trying to create simple crud application using postgres and jpa when i trying running this project im getting this error shared below ,
its is something related to ...
0
votes
1
answer
42
views
How to scan and autowire repositories of an external jar from spring boot application?
I have a spring boot multi-module project where module contains @Repository and @Entity classes .
We create a jar out of this module and add it as a external library in main Spring boot application.
...
2
votes
3
answers
116
views
one-to-many: JPA generates wrong FK while using ddl-auto=create-drop
It seems that I made a mistake somewhere but I can not see where.
JPA insists on generating a unique constraint on a FK of one-to-many relationship on the child side. This constraint prevents me from ...
0
votes
0
answers
24
views
JpaRepository Whitelabel Error Page - This application has no explicit mapping for /error
I am trying to extend my implementation by adding a second repository (Review). However, when I try to access http://localhost:8080/api/reviews I get the above error. Can anyone spot where I've ...
0
votes
0
answers
63
views
Spring Repository - Is it OK creating a @Repository class only for a specific stored procedure?
I have to call a stored procedure in my project and it requires:
validation if a temp database exists
create this temp db if needed
execute insert statements in this temp db
call stored procedure ...
0
votes
1
answer
55
views
Why I'm getting error while running Spring Boot application that define bean of type 'com.exam.repo.UserRepository' in your configuration?
package com.exam.examserver;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import ...
0
votes
1
answer
43
views
How to filter rows from a table based on "If at least one common value in list of string and a column that has list of string"
I have one string students = "Ram,Jack,jim.. and so on";
I have one table called sports_group which is as below:
Sport_id
name
school
city
Fb100
Atul,Mani,Ram,Gopal
St. marry
Delhi
...
0
votes
1
answer
57
views
Repository not deleting resources in H2 in-memory database
I have set up a simple User model and repository and a controller as follows:
import jakarta.persistence.*;
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(...
0
votes
0
answers
78
views
Spring Boot custom CRUD query
I am using Spring Boot to create a basic chore tracker webapp. It renders as shown below, however I have hard coded in these digits so you can see what I am trying to achieve. I am trying to query the ...
1
vote
1
answer
1k
views
Spring data mongodb repository - How to exclude null/blank fields from query using the @Query annotation?
I'm using the Spring-data-mongodb repository framework in my Spring Boot project. I have an API where users can specify 1+ query parameters when searching for an object, and I would like to convert ...
0
votes
2
answers
98
views
How to change for Postgresql the string value for json in jpa repository @Query using springboot
Maven pom dependency:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime&...
-1
votes
1
answer
103
views
I am trying to use JPA in my servlet project but i am unsable to do so i am getting error that my repository is null i am unable to fix this problem
Here is my servlet code
package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org....
7
votes
3
answers
5k
views
Spring: Native Query in batch using query annotation in a Repository?
I've got to do upserts of thousands of records at a time, broken into batches of let's say 25 actual upserts at a time. The upsert is based on a unique constraint being service+key, and if the insert ...
0
votes
1
answer
152
views
Deleted items affect to pagination
I need iterate over big amount of users (10000k+) and on each user process some logic like checking if user match my delete condition, and if yes, then send email and delete user in database.
This is ...
1
vote
1
answer
112
views
Autowired annotation not working on variable of another package for customClass extending SimpleJpaRepository
I have spring boot application service, In the handler class of this application service using IDGenerator class of package Utils, Autowired annotations works for Variable of the IDGenerator in ...
0
votes
1
answer
1k
views
Error creating bean with name 'entityManagerFactory' Factory method 'entityManagerFactory' threw exception with message
I have a webapp with maven, eclipselink, jpa, spring 5, jsf2.3, java 8, primefaces 11 deployed on tomcat 8.5.
For a software modernization question I just successfully ported to tomcat 9 with java 17 ...
0
votes
0
answers
241
views
I am trying to junit test repository , getting null pointer exception
THIS IS THE CODE
I WANT TO WRITE JUNITS FOR REPOSITORYY, AND TEST findByName() method
public interface CodeRepository extends JpaRepository<CodeEntity, Integer> {
CodeEntity ...
0
votes
2
answers
182
views
UnsatisfiedDependencyException:Error creating bean with name 'jdbcIngredientRepository':Unsatisfied dependency expressed through constructor parameter
I am referring book "Spring in Action 6th edition" , chapter 3 - Storing data using JDBC Template
I got the following issue
org.springframework.beans.factory.UnsatisfiedDependencyException: ...
0
votes
2
answers
62
views
Update LastModifiedDate of owned entity
I have two objects. Workflow and Task. Task does contain workflow.
@Entity
public class Workflow {
@Column(name = "last_modified_date")
private Date lastModifiedDate;
...}
@Entity
@...
1
vote
1
answer
390
views
Why JPA repositories have to be linked to a transaction manager?
I don't understand why JPA repositories have to be linked to a transaction manager.
@EnableJpaRepositories(
basePackages = "com.ieci.mugeju.data.repositories1",
entityManagerFactoryRef = &...
2
votes
1
answer
178
views
Spring data doesn't add fragment to repository
I have a Spring repository that I try to customize. I use fragments because I need a spring bean wired to perform my logic.
Here is the interface I'm using to override the standard logic:
@...
0
votes
1
answer
127
views
Spring Data enum usage for in clause
I have an entity define below
@Entity
public class MyActions {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Enumerated(EnumType.STRING)
private MyEnum name;//...
0
votes
1
answer
88
views
Adding @deleteMapping to Spring Boot Rest service causes UnsatisifedDependencyException and NullPointerException
I am making a Spring Boot Rest service and have encountered an issue when I add in a delete mapping. Before I added it the code worked fine and ran without issue, now when I try and compile it in the ...
0
votes
1
answer
445
views
Field postRepository in BlogController required a bean of type 'PostRepository' that could not be found
I am writing simple Java Spring boot MVC web application.
It contains crud operations for manipulating with blog elements such as posts.
I have one error:
Error starting ApplicationContext. To display ...
0
votes
2
answers
103
views
Spring Repository save() method doesn't return the rounded value
Save() returns the saved object with wrong attributes, the attribute "price" should return a rounded value.
Let's say I have the following table:
CREATE TABLE OBJ(
ID INT PRIMARY KEY ...
0
votes
1
answer
297
views
Missing Swagger documentation with Springdoc for @RepositoryRestResource
I've created annotated repository, but no Swagger definition is visible
@RepositoryRestResource(path = "InstanceUptime")
public interface InstanceUptimeRepository extends JpaRepository<...
0
votes
1
answer
336
views
Multiple databases (Postgresql in RDS) but same spring repository and entity
I have a use case where I need to create exact same postgresql database in two different regions. Everything is same in these two databases i.e same schema and same tables and same data.
I have a use ...
1
vote
1
answer
339
views
@Autowired not working in multi-module application
I need to @Autowire database services or repositores form "database" module in "game" module.
Already added those annotations in main "Application" class:
@Configuration
@...
0
votes
1
answer
385
views
The method search(BoolQueryBuilder) is undefined for the type
I just migrate my spring boot from 2.2.4-RELEASE with spring-data-elastic-search 3.2.4 to spring boot 2.6.5 with spring-data-elastic-search 4.3.3.
My code here
public Iterable ...
0
votes
1
answer
112
views
Spring Boot: Filter by using array
New to spring here, I was wondering how can I search by multiple genres in the following example. Basically, what I have now returns all content that contains any string in the array of genre, while I ...
0
votes
1
answer
392
views
Spring specification query for one to many join and sum of field is grater then given value
I am creating filter using joining this three entity seeker_job_application,seeker_profile and seeker_experience. where I want achieve result as below query.
In filter I want to find out ...
0
votes
1
answer
422
views
How to simulate lombok @data stackoverflow error within unit tests for repository class?
I have a relationship between entities that throws a stack overflow error if the @Data annotation from Lombok is used instead of the individual @Getter and @Setter annotations. This is fixed now, but ...
0
votes
0
answers
621
views
Caused by: java.lang.IllegalArgumentException: Not a managed type: class fr.projettresscientifique.reel.referentielreel.model.jpa.CapteurJpa JPA
I am trying to create a Jpa repository for a Capteur Class.
I have javax and not jakarta.
Here is my class.
package fr.projettresscientifique.reel.referentielreel.model.jpa;
import java.util.UUID;
...
-1
votes
1
answer
208
views
Parameter 0 of constructor in com.earworm.backendearworm.UserService required a bean of type
Me and my team are having trouble getting our spring boot application to run and we try to fix one thing that then leads to another error. I have been looking around but cant seem to find the answer. ...
1
vote
2
answers
579
views
What is difference between Neo4jRepository and ReactiveNeo4jRepository?
I am presently building a Spring Boot backend with REST APIs, which is backed by Neo4j Database. So, while going through the official documentations of Spring Data Neo4j I have observed the usage of ...
2
votes
1
answer
2k
views
How can I mock a call to Spring's repository `saveAll()` method using mockk?
I am using Mockk as my mocking framework when testing my Spring Boot Data repository interfaces.
Actually I am doing the following
every { itemRepository.saveAll(listOf(any(), any())) } returns listOf&...
0
votes
0
answers
264
views
How does Spring JPA Repository save() method handle auto_increment columns?
Say we input username: hello The entity below save the user info in User regU
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int user_id;
...
0
votes
1
answer
1k
views
Spring data JPA. Add record (insert data) as "foreign key id" opposed to as a "entity". Is there a difference?
I couldn't find the answer to my question, I hope this is not a duplicate question.
Below is illustrated made-up example.
Database model
data table "user":
+--+--------+
|id|username|
+--+-...
1
vote
0
answers
74
views
How To return a Object constructed via JPA Repository Query with a Join
Let's say I have 2 tables- Order and OrderHistory. Order has a primary key but OrderHistory doesn't and I've added a fake key for it for the below join.
The join is to get a resultset
@Query(value=&...
0
votes
0
answers
39
views
jpa , Hibernate, Spring data jpa and repositories
Hi guys I know that hibernate is a jpa implementation and spring data jpa is an abstraction of access to jpa data, but I need to know the relation between them how does they work.
0
votes
0
answers
412
views
Spring, How to use repository polymorphism to return all data
I want to be able to create repository based on interface type. I did a little research and I got it work with this code:
interface Animal { }
@Document
class Dog extends Animal { }
@Document
class ...
0
votes
1
answer
193
views
How can I create queries with sort and where in MongoDB with Spring Repository interface?
I am trying to make a specific query in a MongoDB collection with SpringBoot. There are lots of results with the query that can be seen here. I am trying to sort and filter the results as I did in ...
0
votes
2
answers
1k
views
How to get number of rows deleted using deleteAll()?
I want to get number of deleted rows with deleteAll() using SpringRepository. It is pretty simple to obtain this if I write my own function, just like in this thread. However, I want to override ...
1
vote
1
answer
3k
views
Spring batch RepositoryItemWriter not working
I have a scenario where a given json file Employee.json needs to be read to Employee object and then written to employee table in mysql database in a batch process.
Employee.json:
[
{
...
0
votes
2
answers
773
views
How to delete a field in all documents of mongodb collection using MongoRepositoty @Query
I have a collection:
public class Person {
private String name;
private Integer age;
}
I want to delete field age in all the documents. So the schema gonna look like that:
public class Person {
...
0
votes
1
answer
824
views
Spring Data Repository not working with Generics
I'm playing around with generics and Spring Data repository. I created a simple project with almost zero configuration, entities are in subpackage of main class.
Entity
@Data
@ToString(callSuper = ...
0
votes
2
answers
2k
views
Field userRepository in com.x.x.service.UserServiceImpl required a bean of type 'com.x.x.repository.UserRepository' that could not be found
Good morning ! despite all my research I can not solve this problem with application spring someone can help me I use jdk 17;
My Service class
@Service
public class UserServiceImpl implements ...
3
votes
1
answer
2k
views
Specify complex sorting criteria when requesting Spring Data JPA repository
I'm requesting paged and sorted data from my database, specified via Pageable with following repository API:
org.springframework.data.jpa.repository.JpaSpecificationExecutor.findAll(Specification<...
0
votes
0
answers
278
views
Unable to unit test a spring service calling mocked custom repository
I defined a custom repository Interface which get stream of entities through Query.getResultStream
public interface MyRepository<T> {
Stream<T> findByCriteria(...);
}
public class ...
0
votes
1
answer
2k
views
Error in creating bean userController caused by Could not create query for public abstract java.util.optional
Stack trace:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController':
Unsatisfied dependency expressed through field 'userRepository'; nested ...