/** * Constructs a join description. * * @param rhsType Type of the new entity * @param rhsAlias The alias to be used when referencing field of the joined type */ public Join(String schemaName, Class rhsType, String rhsAlias) { this(schemaName, TypeDescriptor.get(rhsType), rhsAlias); }
/** * Constructs a join description. * * @param rhsType Type of the new entity */ public Join(Class rhsType) { this(rhsType, TypeDescriptor.get(rhsType).getTableAlias()); }
/** * Constructs a join description. * * @param rhsType Type of the new entity * @param rhsAlias The alias to be used when referencing field of the joined type */ public Join(Class rhsType, String rhsAlias) { this(null, TypeDescriptor.get(rhsType), rhsAlias); }
private List getNextSequenceImpl(TypeDescriptor typeDescriptor, Session session) { Field[] pkFields = typeDescriptor.getPkFields(); Assert.condition( 1 == pkFields.length, "Automatic PK values are only supported for types with a single PK field."); String createPKStmt = dbDescriptor.getCreatePKStatement( sqlUtils.getSchemaName(), typeDescriptor.getPkSequence(), this.sequenceBatchSize); Field field = pkFields[0]; if (session.isUsingPreparedStatements(typeDescriptor.getType())) { PreparedStatement pkStatement = null; try { Connection connection = session.getConnection(); PreparedStatement result; try { result = connection.prepareStatement(createPKStmt); } catch (SQLException x) { throw new InternalException(x); } pkStatement = result; ResultSet pkQuery = pkStatement.executeQuery(); List newIds = new LinkedList(); while (pkQuery.next()) { newIds.add( DmlManager.getJavaValue( field.getType(), typeDescriptor.getPersistentField(field).getLength(), pkQuery, 1, true, false)); } return newIds; } catch (SQLException e) { throw new InternalException(e); } finally { QueryUtils.closeStatement(pkStatement); } } else { Statement pkStmt = null; try { Connection connection = session.getConnection(); pkStmt = connection.createStatement(); ResultSet pkQuery = pkStmt.executeQuery(createPKStmt); List newIds = new LinkedList(); while (pkQuery.next()) { newIds.add( DmlManager.getJavaValue( field.getType(), typeDescriptor.getPersistentField(field).getLength(), pkQuery, 1, true, false)); } return newIds; } catch (SQLException e) { throw new InternalException(e); } finally { QueryUtils.closeStatement(pkStmt); } } }