/* */ {
/* 1177 */ StringBuffer buf = (StringBuffer)data;
/* */
/* 1180 */ ASTPath toPath = (ASTPath)node.jjtGetChild(1);
/* */
/* 1182 */ JDBCCMRFieldBridge toCMRField = (JDBCCMRFieldBridge)toPath.getCMRField();
/* */
/* 1184 */ JDBCEntityBridge toChildEntity = (JDBCEntityBridge)toPath.getEntity();
/* */
/* 1186 */ String pathStr = toPath.getPath(toPath.size() - 2);
/* 1187 */ String toParentAlias = this.aliasManager.getAlias(pathStr);
/* 1188 */ String toChildAlias = this.aliasManager.getAlias(toPath.getPath());
/* 1189 */ String relationTableAlias = null;
/* 1190 */ if (toCMRField.getRelationMetaData().isTableMappingStyle())
/* */ {
/* 1192 */ relationTableAlias = this.aliasManager.getRelationTableAlias(toPath.getPath());
/* */ }
/* */
/* 1196 */ String fromAlias = null;
/* 1197 */ int fromParamNumber = -1;
/* 1198 */ if ((node.jjtGetChild(0) instanceof ASTParameter))
/* */ {
/* 1200 */ ASTParameter fromParam = (ASTParameter)node.jjtGetChild(0);
/* */
/* 1203 */ verifyParameterEntityType(fromParam.number, toChildEntity);
/* */
/* 1205 */ fromParamNumber = fromParam.number;
/* */ }
/* */ else
/* */ {
/* 1209 */ ASTPath fromPath = (ASTPath)node.jjtGetChild(0);
/* 1210 */ addJoinPath(fromPath);
/* */
/* 1212 */ JDBCEntityBridge fromEntity = (JDBCEntityBridge)fromPath.getEntity();
/* 1213 */ fromAlias = this.aliasManager.getAlias(fromPath.getPath());
/* */
/* 1216 */ if (!fromEntity.equals(toChildEntity))
/* */ {
/* 1218 */ throw new IllegalStateException("Only like types can be compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toChildEntity.getEntityName());
/* */ }
/* */
/* */ }
/* */
/* 1226 */ addLeftJoinPath(pathStr, toPath);
/* */
/* 1229 */ if (!this.subquerySupported)
/* */ {
/* 1231 */ addJoinPath(toPath);
/* */
/* 1234 */ if (node.not)
/* */ {
/* 1236 */ buf.append(" NOT ");
/* */ }
/* 1238 */ buf.append('(');
/* */
/* 1240 */ if (relationTableAlias == null)
/* */ {
/* 1242 */ SQLUtil.getIsNullClause(true, toChildEntity.getPrimaryKeyFields(), toChildAlias, buf);
/* */ }
/* */ else
/* */ {
/* 1246 */ SQLUtil.getIsNullClause(true, toCMRField.getTableKeyFields(), relationTableAlias, buf);
/* */ }
/* */
/* */ }
/* */ else
/* */ {
/* 1252 */ if (node.not)
/* */ {
/* 1254 */ buf.append(" NOT ");
/* */ }
/* */
/* 1257 */ buf.append("EXISTS ").append('(');
/* */
/* 1259 */ if (relationTableAlias == null)
/* */ {
/* 1261 */ buf.append("SELECT ");
/* 1262 */ SQLUtil.getColumnNamesClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, buf).append(" FROM ").append(toChildEntity.getQualifiedTableName()).append(' ').append(toChildAlias).append(" WHERE ");
/* */
/* 1268 */ SQLUtil.getJoinClause(toCMRField, toParentAlias, toChildAlias, buf);
/* */ }
/* */ else
/* */ {
/* 1272 */ buf.append("SELECT ");
/* 1273 */ SQLUtil.getColumnNamesClause(toCMRField.getRelatedCMRField().getTableKeyFields(), relationTableAlias, buf).append(" FROM ").append(toCMRField.getQualifiedTableName()).append(' ').append(relationTableAlias).append(" WHERE ");
/* */
/* 1279 */ SQLUtil.getRelationTableJoinClause(toCMRField, toParentAlias, relationTableAlias, buf);
/* */ }
/* */ }
/* */
/* 1283 */ buf.append(" AND ");
/* */
/* 1286 */ if (fromAlias != null)
/* */ {
/* 1289 */ if (relationTableAlias == null)
/* */ {
/* 1291 */ SQLUtil.getSelfCompareWhereClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, fromAlias, buf);
/* */ }
/* */ else
/* */ {
/* 1298 */ SQLUtil.getRelationTableJoinClause(toCMRField.getRelatedCMRField(), fromAlias, relationTableAlias, buf);
/* */ }
/* */
/* */ }
/* */ else
/* */ {
/* 1307 */ this.inputParameters.addAll(QueryParameter.createParameters(fromParamNumber - 1, toChildEntity));
/* */
/* 1311 */ if (relationTableAlias == null)
/* */ {
/* 1313 */ SQLUtil.getWhereClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, buf);
/* */ }
/* */ else
/* */ {
/* 1317 */ SQLUtil.getWhereClause(toCMRField.getRelatedCMRField().getTableKeyFields(), relationTableAlias, buf);
/* */ }
/* */
/* */ }
/* */
/* 1323 */ buf.append(')');