HHH-8447 HQL delete with multiple subqueries failing (incorrect alias
used)
This commit is contained in:
parent
cc550c08a8
commit
714d48880d
|
@ -356,10 +356,6 @@ class FromElementType {
|
|||
return propertyMapping.toColumns(tableAlias, path);
|
||||
}
|
||||
|
||||
if (fromElement.getWalker().getCurrentClauseType() == HqlSqlTokenTypes.SELECT) {
|
||||
return propertyMapping.toColumns(tableAlias, path);
|
||||
}
|
||||
|
||||
if (fromElement.getWalker().isSubQuery()) {
|
||||
// for a subquery, the alias to use depends on a few things (we
|
||||
// already know this is not an overall SELECT):
|
||||
|
@ -383,6 +379,10 @@ class FromElementType {
|
|||
return propertyMapping.toColumns(tableAlias, path);
|
||||
}
|
||||
|
||||
if (fromElement.getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.SELECT) {
|
||||
return propertyMapping.toColumns(tableAlias, path);
|
||||
}
|
||||
|
||||
if ( isManipulationQuery() && isMultiTable() && inWhereClause() ) {
|
||||
// the actual where-clause will end up being ripped out the update/delete and used in
|
||||
// a select to populate the temp table, so its ok to use the table alias to qualify the table refs
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.junit.Test;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class DeleteWhereMemberOfTest extends BaseCoreFunctionalTestCase {
|
||||
public class DeleteWithSubqueryTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
|
@ -45,7 +45,9 @@ public class DeleteWhereMemberOfTest extends BaseCoreFunctionalTestCase {
|
|||
Attrset.class,
|
||||
Attrvalue.class,
|
||||
Employee.class,
|
||||
Employeegroup.class
|
||||
Employeegroup.class,
|
||||
Panel.class,
|
||||
TrtPanel.class
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -63,4 +65,16 @@ public class DeleteWhereMemberOfTest extends BaseCoreFunctionalTestCase {
|
|||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue( jiraKey = "HHH-8447" )
|
||||
public void testDeleteMultipleWhereIns() {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
s.createQuery("DELETE FROM Panel panelEntity WHERE " +
|
||||
" panelEntity.clientId IN ( SELECT trtPanel.clientId FROM TrtPanel trtPanel ) " +
|
||||
" AND panelEntity.deltaStamp NOT IN ( SELECT trtPanel.deltaStamp FROM TrtPanel trtPanel )").executeUpdate();
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package org.hibernate.test.hql;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Panel implements Serializable {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private Long clientId;
|
||||
|
||||
private String deltaStamp;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(Long clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getDeltaStamp() {
|
||||
return deltaStamp;
|
||||
}
|
||||
|
||||
public void setDeltaStamp(String deltaStamp) {
|
||||
this.deltaStamp = deltaStamp;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.hibernate.test.hql;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class TrtPanel implements Serializable {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
private Panel panel;
|
||||
|
||||
private Long clientId;
|
||||
|
||||
private String deltaStamp;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Panel getPanel() {
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void setPanel(Panel panel) {
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(Long clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getDeltaStamp() {
|
||||
return deltaStamp;
|
||||
}
|
||||
|
||||
public void setDeltaStamp(String deltaStamp) {
|
||||
this.deltaStamp = deltaStamp;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue