Skip to content
Advertisement

Tag: hibernate

Using TIMESTAMPDIFF with JPA criteria query and hibernate as the provider

I have a data table with columns setup and release, both of which hold timestamps. My goal is to create an equivalent of the SQL query below using CriteriaQuery. SQL Query:SELECT TIMESTAMPDIFF(SECOND, setup, released)) as sum_duration FROM calls The CriteriaBuilder#diff() function clearly does not work as it requires parameters that are Numbers, so I tried using CriteriaBuilder#function: However, when I

Why does not Hibernate set @DynamicInsert by default

Could anyone explain to me why Hibernate does not set the @DynamicInsert annotation by default and allow entities to generate an INSERT based on the currently set properties? What’s the reason for not using @DynamicInsert and, therefore, including all entity properties by default? Answer What @jb-nizet said. Also, dynamic-insert=”true” is a bad idea in my book. Skipping null fields from

JPA with HIBERNATE insert very slow

I am trying to insert some data to SQL Server 2008 R2 by using JAP and HIBERNATE. Everything “works” except for that it’s very slow. To insert 20000 rows, it takes about 45 seconds, while a C# script takes about less than 1 second. Any veteran in this domain can offer some helps? I would appreciate it a lot. Update:

Inserting NULL into MySQL timestamp

I’m observing unexpected behavior with inserting/updating NULL in a MySQL timestamp column. Consider the following statements. The first insert (when hiredate is not specified in the SQL, hireDate is null(0) which is expected. However when an explicit null passed in SQL, the current date time is inserted which is unexpected. Why does this happen? Note: Hibernate uses second type of

NonUniqueDiscoveredSqlAliasException when two table has same column names

I have two tables Item and Nikasa – whose definitions looks like: Item { id, name, spec} and Nikasa {id, date, item_id}. Here item_id represents Item.id. I did a simple native SQL join to select only Item.id and Nikasa.id as: But I am getting exception NonUniqueDiscoveredSqlAliasException : Encountered a duplicated sql alias [ID] during auto-discovery of a native-sql query at

Advertisement