Scott Roehrig ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *commented* on HHH-14152 ( https://hibernate.atlassian.net/browse/HHH-14152?atlOrigin=eyJpIjoiY2Q3Nm... )
Re: Query fails after upgrading to 5.4.20.Final ( https://hibernate.atlassian.net/browse/HHH-14152?atlOrigin=eyJpIjoiY2Q3Nm... )
Providing the source isn’t possible as it is commercially licensed code. I have been able to debug this further and I may have narrowed the issue down. I wrote a second test case as follows:
final EntityManager manager = com.gemalto.ics.usplatform.bip.persistence.EntityManagerFactory.newInstance().createEntityManager();
{{try { }}
Query query = manager.createNativeQuery("SELECT IDENTIFIER FROM ISSUERS WHERE ISSUER = 1 AND IDENTIFIER = '1'"); query.setHint(QueryImpl.QUERY_HINT_READ_ONLY, true); List<Object> results = query.getResultList(); query = manager.createNativeQuery("SELECT IDENTIFIER FROM RESOURCES WHERE ISSUER = 1 AND IDENTIFIER = '1'"); query.setHint(QueryImpl.QUERY_HINT_READ_ONLY, true); results = query.getResultList(); query = manager.createQuery( "SELECT DISTINCT resource FROM IssuerImpl resource WHERE resource.identifier = :identifier"); query.setParameter("identifier", new com.gemalto.ics.usplatform.bip.IdentifierImpl(1L, "1")); query.setHint(QueryImpl.QUERY_HINT_READ_ONLY, true); results = query.getResultList();
{{} finally
{ manager.close();}
}}
What I found is interesting. The FIRST query which looks at the CHILD table ISSUERS finds the ROW in 5.4.19/5.4.20. BUT, in 5.4.20 the parent table RESOURCES is missing the row while it is not missing the row in 5.4.19. This only happens when the persistence.xml is configured to create the tables and structure at runtime (in unit tests for instance). The structure is created via a create.sql and a load.sql.
In 5.4.19 that function works correctly and the tables have the proper entries required for the tests inserted via load.sql. In 5.4.20, they do not however. What is interesting is there are FK relations across the ISSUERS table rows to the parent RESOURCES table as it is a secondary JOIN table, but it is not being violated in 5.4.20.
So, I would hypothesize that something perhaps in the MultiLine extractor has changed? I did notice there was a backport of a change in that area in 5.4.20 in the issues list.
But the problem appears to be on the “creation” side and not a regression in the actual query itself. Which explains why the exact query works in 5.4.19 but fails in 5.4.20 which was utterly confusing for a bit 🙂
I am going to see if I can convert to not using the multi line reader in persistence.xml and if that makes any difference. But the issue appears to be related to the creation/loading of the database via the persistence.xml and not the runtime query failing so to speak.
( https://hibernate.atlassian.net/browse/HHH-14152#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14152#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100144- sha1:b6d623e )
François DAMBRINE ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5c07a50... ) *commented* on HHH-14153 ( https://hibernate.atlassian.net/browse/HHH-14153?atlOrigin=eyJpIjoiNDUzZj... )
Re: HQL update query with multiple condition generates temporary tables on SQLServer ( https://hibernate.atlassian.net/browse/HHH-14153?atlOrigin=eyJpIjoiNDUzZj... )
I don’t know how to extract a test case out of this. If you can provide some tips about it I will post one.
Here is the minimal model to reproduce the issue
@Entity(name = "abstracttaskentity" )
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class AbstractTaskEntity {
@Id
@Type(type = "uuid- char " )
@Column(name = "id" )
private UUID taskId;
@NotNull
private String name;
private String description;
private boolean locked;
public UUID getTaskId() {
return taskId;
}
public void setTaskId(UUID taskId) {
this.taskId = taskId;
}
public boolean isLocked() {
return locked;
}
/**
* @param locked
*/
public void setLocked( boolean locked) {
this.locked = locked;
}
public String getName() {
return name;
}
/**
* @param name
*/
public void setName( String name) {
this.name = name;
}
public String getDescription() {
return description;
}
/**
* @param description
*/
public void setDescription( String description) {
this.description = description;
}
}
Then one implementing class
@Entity(name = "webtaskentity" )
public class WebTaskEntity extends AbstractTaskEntity {
private String sessionId;
public String getSessionId() {
return sessionId;
}
public void setSessionId( String sessionId) {
this.sessionId = sessionId;
}
}
To have more information : the entity is persisted through the entity manager by a web handler.
Then a background-running thread find out the task and tries to lock it with the query I gave in the issue.
( 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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100144- sha1:b6d623e )