Skip to content
Advertisement

Tag: spring-data-jpa

Spring boot JPA repository passed to another thread not working

I have an autowired jpa repository object working. However, I need to use it to add rows into the database from multiple threads. Though, after passing it to another thread, it fails. Code structure However, doing a dbRepository.save() from a thread safe class, I get error cause: java.lang.IllegalStateException: org.springframework.context.annotation.AnnotationConfigApplicationContext@41330d4f has been closed already detailedMessage: Error creating bean with name ‘spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties’:

In which cases does JpaRepository automatically create the query without you having to use @Query annotation

I am following a Udemy tutorial in Spring boot. There’s a part where @Query wasn’t used for a user-created method in the repository interface. It works, but I want to understand when JpaRepository takes care of the creation of query. In the User class below, @Table wasn’t used. findByEmail(String email) method works without any implementation/definition. So, my impression was that,

How use generic entity name in JPQL

I have three tables with same column name and types, what changes is just the table name. Example: | TABLE1 | TABLE2 | TABLE3 | | —— | —— | ——- | | ID | ID | ID | | NAME | NAME | NAME | | FOO | FOO | FOO | | BAR | BAR | BAR |

Spring Find by unique properties

Given 1 relational table Doctor_ID Client_ID 2 2 2 3 2 4 3 5 4 2 4 3 And I want all the occurrences where client_id is not equals to 3, ignoring the same doctor_id. In this example, I would only get the 4th row… Doctor_ID Client_ID 3 5 How could I achieve something like that? Answer This query with

Spring Data JPA: FindBy on Join Column

I have setup two entities like below in a one-to-one mapping and I am trying to query on the joincolumn like below in my repository: In my BRepository.java, I am trying to do this: I get the following error: No property a found for type B! Did you mean ‘aId’? Is this not the right way to query on a

querydsl: java.lang.NoSuchFieldError: TREATED_PATH

springboot version is 2.51, java vsersion 1.8 it will crash in selectFrom(), erro info: java.lang.NoSuchFieldError: TREATED_PATH how to resolve it,i cant find a way in web there is my code there is dependency BmsPost.java Answer You have mixed versions of querydsl. I guess you are having querydsl-core version 4.4.x while your querydsl-jpa is of version 5.0.0.M1. (this is probably caused

How to ignore a field from DB [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I have a list of persons in DB everyone having a CV field which is a MultiPart File in Spring. I’m trying to get all

Advertisement