public AssignmentSpecification(AST eq, Queryable persister) { if (eq.getType() != HqlSqlTokenTypes.EQ) { throw new QueryException("assignment in set-clause not associated with equals"); } this.eq = eq; this.factory = persister.getFactory(); // Needed to bump this up to DotNode, because that is the only thing which currently // knows about the property-ref path in the correct format; it is either this, or // recurse over the DotNodes constructing the property path just like DotNode does // internally final PathSeparatorNode lhs = (PathSeparatorNode) eq.getFirstChild(); final SqlNode rhs = (SqlNode) lhs.getNextSibling(); validateLhs(lhs); final String propertyPath = lhs.getPropertyPath(); Set<String> temp = new HashSet<String>(); // yuck! if (persister instanceof UnionSubclassEntityPersister) { final String[] tables = persister.getConstraintOrderedTableNameClosure(); Collections.addAll(temp, tables); } else { temp.add( persister.getSubclassTableName(persister.getSubclassPropertyTableNumber(propertyPath))); } this.tableNames = Collections.unmodifiableSet(temp); if (rhs == null) { hqlParameters = new ParameterSpecification[0]; } else if (isParam(rhs)) { hqlParameters = new ParameterSpecification[] {((ParameterNode) rhs).getHqlParameterSpecification()}; } else { List parameterList = ASTUtil.collectChildren( rhs, new ASTUtil.IncludePredicate() { public boolean include(AST node) { return isParam(node); } }); hqlParameters = new ParameterSpecification[parameterList.size()]; Iterator itr = parameterList.iterator(); int i = 0; while (itr.hasNext()) { hqlParameters[i++] = ((ParameterNode) itr.next()).getHqlParameterSpecification(); } } }
@Override public void execute(Connection connection) { try { Statement statement = connection.createStatement(); try { statement.executeUpdate(persister.getTemporaryIdTableDDL()); persister .getFactory() .getServiceRegistry() .getService(JdbcServices.class) .getSqlExceptionHelper() .handleAndClearWarnings(statement, CREATION_WARNING_HANDLER); } finally { try { statement.close(); } catch (Throwable ignore) { // ignore } } } catch (Exception e) { log.debug("unable to create temporary id table [" + e.getMessage() + "]"); } }