François DAMBRINE (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5c07a50...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMzFmYWRhMGRk...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-14153?atlOrigin=eyJpIjoiMzFmYW...
) HHH-14153 (
https://hibernate.atlassian.net/browse/HHH-14153?atlOrigin=eyJpIjoiMzFmYW...
) HQL update query with multiple condition generates temporary tables on SQLServer (
https://hibernate.atlassian.net/browse/HHH-14153?atlOrigin=eyJpIjoiMzFmYW...
)
Issue Type: Bug Affects Versions: 5.4.10, 5.4.19 Assignee: Unassigned Components:
hibernate-core Created: 13/Aug/2020 00:14 AM Environment: Windows Server 2019
SQLServer 2016
hibernate-core 5.4.19 (also tested with 5.4.10)
hibernate-c3p0 5.4.19 (also tested with 5.4.10)
Labels: HQL Priority: Major Reporter: François DAMBRINE (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5c07a50...
)
When we try to run an HQL UPDATE query that will update a table with a set of two
conditions, hibernate split the query in three parts :
* create a temp table
* insert all matching records in this table
* launch update query
This only happen with SQLServer, the main issue is that HHH-3326 (
https://hibernate.atlassian.net/browse/HHH-3326 ) Open is not yet fixed, so, when the
SQLServer tempdb has a collation that is not compatible with our current db, the query
just fails with a collation conflict.
*Minimal code to reproduce*
Query q = entityManager.createQuery( "UPDATE abstracttaskentity e SET
"
+ "e.locked = true "
+ "WHERE e.locked = false AND e.taskId = :id" );
q.setParameter( "id" , taskToAcquire.getTaskId());
entityManager.getTransaction().commit();
*Hibernate query log*
Hibernate:
create table #abstracttaskentity (
id varchar(255) not null
)
Hibernate:
insert
into
#abstracttaskentity
select
abstractta0_.id as id
from
abstracttaskentity abstractta0_
where
abstractta0_.locked=0
and abstractta0_.id=?
Hibernate:
update
abstracttaskentity
set
locked=1,
where
(
id
) IN (
select
id
from
#abstracttaskentity
)
(
https://hibernate.atlassian.net/browse/HHH-14153#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-14153#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100144- sha1:b6d623e )