I’m writing a simple Spring Data JPA application. I use MySQL database. There are two simple tables: Department Employee Each employee works in some department (Employee.department_id). The method getAll returns a list with duplicated departments (each department is repeated as many times as there are employees in this department). Question 1: Am I rigth that this is a feature related
Tag: spring-data-jpa
Unable to locate appropriate constructor on class [ClassName]
I want to send a sql query by using Spring JPA like : However, when I remove some fields like “ms.width”, I get the error: I understand that return Object[] cannot be parsed to DTO object. If I write constructor without the parameter – “Width”, it will work properly. However, I want to provide that a query can be sendable
(N + 1) selects problem with child Map-collection
friends! I have these entities: Document: and ChangeNotice: And these are my repositories: For Document: and for ChangeNotice: So, when i want to get Document with changeNotices, thats not a problem, i have only one select. But when i want to get ChangeNotice with documents – i have (n + 1), first for document, and n for changeNotices Map. I
SQL select data based on a one to many relation
I struggle a little with the following database entity relations: I would like to create a query where I get all events for a user that is either the owner (item-user_id) or a participant (participant-user_id) I got back to native queries, cause they are more easy to try out. But the one to many relation between the registration and the
JPA Criteria Builder query with inner SELECT statement
I need to create the below SQL join condition using JPA criteria builder, Below is the entity class and JPA query builder. I am able to build the query with join condition but cannot create the inner SELECT query. How can i create a inner select query for join clause? Requirement description: The below is the input table and output
Database performance: Split table or keep together
For our project we want to save employees and customer in one or two database tables. The customers have the same columns as the employees (e.g. name, address, language, email,…). The employees on the other side do have additional columns like SocialSecurity Number, bankaccount,… Since the two have many similar columns it might be senseful to merge them into a
Spring JPA – Prepared Statement Queries?
I’m building a Spring REST server application and I’m doing some native queries to retrieve data from my database. From the teaching in school, they suggest to make all queries prepared statements, to stop the user entering harmful SQL into the input boxes. I’ve tried to do some research, but have not found a concrete answer. Does Spring use prepared
How to check not null date in spring jpa
I have 2 IF. If No 1, is work for me. Because i wont if data is present and get house keeping == null. for action to update condition,status,and housekeeping. IF no 2, no work for me. I wont if getData is present and get housekeeping is availabe / not null. For action only to update condition Only check ‘null’,
How to execute a native SQL query having INTERVAL clause through Spring Boot JPA?
Not able to execute a native SQL query through Spring Boot Repository layer with JPA in Oracle DB I am trying to write a native SQL query that gets data from a table between the current date and last …
Reading data from a sql database with spring data fails
I’m having a database with existing tables. One of these is called AKTIVE_AUFTRAEGE with the id “AKTIVE_AUFTRAGE_ID” and the second field “ROBOTER_AUFTRAG_ID”. I want to read the data using Spring …