Skip to content
Advertisement

Tag: spring-data-jpa

Spring Data JpaRepository “JOIN FETCH” returns duplicates

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

(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

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’,

Advertisement