Questions tagged [crud-repository]

81 questions
4
votes
2 answers

Cannot invoke "...." because the return value of "..." is null

I am working on small CRUD parking thing. My tables Car and Parking are created with liquibase, please see xml.
user18802229
4
votes
0 answers

Couldn't find PersistentEntity for type class java.time.OffsetDateTime! after Spring boot 2.6 update

I have crudRepository interface with method named findLastUpdatedTimeByName: public interface FooRepository extends CrudRepository { @Query( "SELECT foo.last_updated_time FROM foo WHERE foo.name = :name") …
3
votes
1 answer

How to mock a repository method no matter the parameters with mockito

I'm using spring framework and testing with Junit and mockito. Right now I have a method in my service which is using a few objects I create in the test, let's call them configObject1 and configObject2, I send them to the method as a parameter, and…
3
votes
2 answers

Delete from a JPARepository with an EmbeddedId by a field in the primary key

Currently I have a Spring Boot application using JpaRepository where let's say EmployeePk is firstname, lastname. Is there a way to delete by Primary Key field without having to specify a custom @Query? It's ok to delete…
Bizzaroerik
  • 33
  • 1
  • 6
3
votes
1 answer

Which class does the parsing and query building in spring data JPA repository?

I have read this line in spring docs "The query builder mechanism built into the Spring Data repository infrastructure", can anyone please tell which class exactly does this query building part in spring?
2
votes
2 answers

java.lang.NullPointerException: Cannot invoke "com.proj.my.repository.OrderRepository.save(Object)" because "this.orderRepository" is null

I want to test my orderService, each order has x cartItems, each cartItem is a product. I managed to do some code, and thought I got it right, but encountered a problem : java.lang.NullPointerException: Cannot invoke…
Dadinho2000
  • 77
  • 1
  • 9
2
votes
2 answers

When i change from crudrepository to pagingand sortingrepository there is no save method

When i change from crudrepository to pagingandsortingrepository there is no save method and the application begins to fail error: cannot find symbol courses.save(course); ^ symbol: method…
2
votes
1 answer

Spring not saving many-to-many mapping in DB

I have 2 entities. An Appointment and an Item. They are both independent and we can have multiple items, in multiple appointments. The Appointment class: @Entity(name = "Appointment") @Table(name = "appointment") public class Appointment { @Id …
2
votes
2 answers

find record by Id and another Id in a list

I have a CrudRepository that look like this: public interface MyDocumentRepository extends CrudRepository {} In my object MyDocument I have: @DynamoDBTable(tableName = "MyDocument ") public class MyDocument { …
2
votes
1 answer

How to us a constructor with parameters in a method used by Spring Boot's @RestController annotation to create a request handler

I bought this new book to try to learn Spring Boot quickly. It started out well, and I easily created a REST API. But then we added CrudRepository, and I'm seeing issues with the code as described in the book. Also, there is no code available to…
BenW
  • 737
  • 10
  • 41
2
votes
1 answer

What is the purpose of findAll() returning Iterable in CrudRepository interface

Whenever you have a repository extending CrudRepository such as: @Repository public interface EmployeeRepository extends CrudRepository { //something } and you want to use the method findAll(): Iterable findAll(); You will…
Reader
  • 101
  • 6
1
vote
1 answer

Hibernate attempting to insert null id in CrudRepository

I'm doing some testing on a spring application using an in-memory H2 database. The database has a 'message' table with the schema: CREATE TABLE `message` ( `id` bigint(20) NOT NULL, `body` CLOB, `channels` varchar(500) NOT NULL, `end_date`…
pbuchheit
  • 1,371
  • 1
  • 20
  • 47
1
vote
1 answer

How to restrict bean creation based on DB value in Springboot

I am having Kafka Listener which I want to enable or disable based on Value from DB. I am using @Conditional annotation in which I am trying to get value from the Database through CrudRepository. here is the code: Listener…
Rahul_Mandhane
  • 187
  • 1
  • 11
1
vote
2 answers

Can a method annotated with @Transactional be wrapped inside another method annotated with the same?

I'm developing basic CRUD APIs using Micronaut, wherein a service (let's call this #1) calls another service (let's call this #2) which in turns calls the save method of the CrudRepository. To define atomic work units, I'm using the @Transactional…
1
vote
1 answer

SpringBoot CrudRepository trying to update instead of create new entity

Spring Boot save method is trying to update and returns error like: org.springframework.dao.IncorrectUpdateSemanticsDataAccessException: Failed to update entity [com.xx.xx.Account@78a31407]. Id 1 not found in database. But my database is…
DGulyasar
  • 101
  • 1
  • 8
1
2 3 4 5 6