Java 类org.hibernate.NullPrecedence 实例源码

项目:lams    文件:MySQLDialect.java   
@Override
public String renderOrderByElement(String expression, String collation, String order, NullPrecedence nulls) {
    final StringBuilder orderByElement = new StringBuilder();
    if ( nulls != NullPrecedence.NONE ) {
        // Workaround for NULLS FIRST / LAST support.
        orderByElement.append( "case when " ).append( expression ).append( " is null then " );
        if ( nulls == NullPrecedence.FIRST ) {
            orderByElement.append( "0 else 1" );
        }
        else {
            orderByElement.append( "1 else 0" );
        }
        orderByElement.append( " end, " );
    }
    // Nulls precedence has already been handled so passing NONE value.
    orderByElement.append( super.renderOrderByElement( expression, collation, order, NullPrecedence.NONE ) );
    return orderByElement.toString();
}
项目:lams    文件:Dialect.java   
/**
 * Renders an ordering fragment
 *
 * @param expression The SQL order expression. In case of {@code @OrderBy} annotation user receives property placeholder
 * (e.g. attribute name enclosed in '{' and '}' signs).
 * @param collation Collation string in format {@code collate IDENTIFIER}, or {@code null}
 * if expression has not been explicitly specified.
 * @param order Order direction. Possible values: {@code asc}, {@code desc}, or {@code null}
 * if expression has not been explicitly specified.
 * @param nulls Nulls precedence. Default value: {@link NullPrecedence#NONE}.
 * @return Renders single element of {@code ORDER BY} clause.
 */
public String renderOrderByElement(String expression, String collation, String order, NullPrecedence nulls) {
    final StringBuilder orderByElement = new StringBuilder( expression );
    if ( collation != null ) {
        orderByElement.append( " " ).append( collation );
    }
    if ( order != null ) {
        orderByElement.append( " " ).append( order );
    }
    if ( nulls != NullPrecedence.NONE ) {
        orderByElement.append( " nulls " ).append( nulls.name().toLowerCase() );
    }
    return orderByElement.toString();
}
项目:lams    文件:SqlGenerator.java   
@Override
protected String renderOrderByElement(String expression, String order, String nulls) {
    final NullPrecedence nullPrecedence = NullPrecedence.parse( nulls,
                                                                sessionFactory.getSettings()
                                                                        .getDefaultNullPrecedence()
    );
    return sessionFactory.getDialect().renderOrderByElement( expression, null, order, nullPrecedence );
}
项目:lams    文件:Settings.java   
public NullPrecedence getDefaultNullPrecedence() {
    return defaultNullPrecedence;
}
项目:lams    文件:Settings.java   
void setDefaultNullPrecedence(NullPrecedence defaultNullPrecedence) {
    this.defaultNullPrecedence = defaultNullPrecedence;
}
项目:lams    文件:OrderByFragmentRenderer.java   
@Override
protected String renderOrderByElement(String expression, String collation, String order, String nulls) {
    final NullPrecedence nullPrecedence = NullPrecedence.parse( nulls, sessionFactory.getSettings().getDefaultNullPrecedence() );
    return sessionFactory.getDialect().renderOrderByElement( expression, collation, order, nullPrecedence );
}
项目:org.fastnate    文件:AllowMissingIdentitySupportDialect.java   
@Override
public String renderOrderByElement(final String expression, final String collation, final String order,
        final NullPrecedence nulls) {
    return this.wrapped.renderOrderByElement(expression, collation, order, nulls);
}
项目:lams    文件:Order.java   
/**
 * Defines precedence for nulls.
 *
 * @param nullPrecedence The null precedence to use
 *
 * @return {@code this}, for method chaining
 */
public Order nulls(NullPrecedence nullPrecedence) {
    this.nullPrecedence = nullPrecedence;
    return this;
}