First the nearest Firebird syntax is
delete from ErpEmploye_AUD e where
exists( select code, folder_codeId, REV from HT_ErpEmploye_AUD ht
where ( hib_sess_id=1 and e.code=ht.code and e.folder_codeId=ht.folder_codeId and e.REV=ht.REV ))
Second the right Hibernate generateDelete code:
private String generateDelete(String tableName, String[] columnNames, String idSubselect, String comment) {
String[] columnEquals = new String[columnNames.length];
for (int i=0;i<columnNames.length;i++){
columnEquals[i] = "tr."+columnNames[i]+"=ht."+columnNames[i];
}
if (idSubselect.contains("where"))
idSubselect = idSubselect.replace("where", "ht where");
else
idSubselect = idSubselect + " ht where";
final Delete delete = new Delete()
.setTableName( tableName+" tr " )
//.setWhere( "(" + StringHelper.join( ", ", columnNames ) + ") IN (" + idSubselect + ")" );
.setWhere( "exists("+ idSubselect +" "+ StringHelper.join( " and ", columnEquals ) + ")" );
if ( factory().getSettings().isCommentsEnabled() ) {
delete.setComment( comment );
}
return delete.toStatementString();
}
I hope that this should be generalised in Hibernate, because this is not a standard code, or could be supported by Firebird