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
Tag: hibernate
JPA batch_size property does not work for native query
I’m trying to make a bulk insert with a native query. I’ve added batch_size property to the application.properties file But in the logs, I see that every insert processed separately. Is it possible to apply batching to native query? Answer If the entities use GenerationType.IDENTITY identifier generator, hibernate will silently disable batch inserts/updates. Please find the following link for the
Case condition in hql
What I’m trying to achieve with this query is: always do the “mother” conditional, but if there isn’t mother, then do the “dad” conditional, is this posible? Answer This query: will try to join first by matching the column idMother to :idMother. If this is not possible then a match of idFather to :idFather will be used, if it exists.
SQL / Hibernate insert only if url not exists
I have a list of urls and a table that contains urls. I want to only insert if the url is not in the table. After the insert the Data-table should be contain: My current attempt is to have a method findByURL(url):List and a call this method for every URL in the list. If the returned list is empty I
Are these SQL queries equivalent? And which is better or is there a better option?
I am working on a Spring web application that utilizes hibernate to connect to a DB2 database. I am try to optimize a service method that gets called may times during a wed service call by reducing …
Can somebody help to translate this MySql query to JPQL or HQL?
Don’t forget to check the image below Objects: 1) Question 2) Tags The relationship is ManyToMany The MySql query is following: Need to translate to JPQL or HQL The main goal is to get list of the most frequency tags like:enter image description here Answer Try: The given JPA query is translated to SQL (by Hibernate) as:
ERROR 1054 (42S22): Unknown column ‘pc.project_id’ in ‘on clause’ even when column project_id exists
I am trying to get a sum from my DB with a query written in hibernate @Query(value = “SELECT COALESCE(sum(charge),0) FROM initial_charge I INNER JOIN task T ON T.id = I.task_id ” +” …
[21000][1242] Subquery returns more than 1 row
My Query: Here I get the error – [21000][1242] Subquery returns more than 1 row By the method of exceptions, I determined that the error in this query string: How to make the correct request so that there is no this error? Thank! Answer Two common ways are aggregation and limiting: However, those are really just hacks to get around
How to compare timestamp in HIBERNATE query?
I have one value of timestamp that I retrieve from the database and then compare it with the current timestamp. I actually want to retrieve data of people who have been logged in for the last two hours. Unfortunately, I am facing this error. please help me, guys. I shall be thankful to you. I have stuck in this code.
What to use: sql migration or entity setups in Spring/Hibernate?
I am little confused, when see, why most programmers use annotation-based setup for database table constraints. For example @Column(unique=true, nullable=false) Why do we need that, if(as I heard) …