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
Tag: jpa
How to use JPA to save datetime of SQL to fix: “Conversion failed when converting date and/or time from character string.”
I got a very frustrated problem.. I cannot use the JPA save function to store correct datetime object of SQL, I got the following error: There is my code: In Controller: In Entity: Many thanks!! Answer I recomend you to use LocalDateTime of modern java.time. JPA automatically convert LocalDateTime into database datetime. To get current datetime use LocalDateTime.now(). You can
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
One to One Mapping Spring boot
Hello everyone in advance I have a problem with my one to one connection when I try to log in to the “user” I get this error what i need is a one to one connection that does not have to be persistent that means a user can have a player but does not have to have it and the
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 ” +” …
Spring Data JPA – Custom Native Query-Methods list prints java.lang.Object
I have created a native custom query method: And calling EntityManager with: But all I get is: when I print out the list. Number of objects is correct so I assume something with casting is not correct. I do get a warning in my IDE: Why is this happening and how do I get the correct list? Answer You can
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.
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
How to add entity to the databse without adding related entitiy in DB as well?
I have a problem adding one entity using JPA save without error : JdbcSQLIntegrityConstraintViolationException: NULL not allowed for column because i add empty entity to the object i want to save. how can i save one entity and tell it’s related one to ignore this transaction? For example i have student and i have student_info OneToOne Relationship. I want to