Skip to content
Advertisement

Tag: hibernate

(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

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

[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.

Advertisement