下面列出了怎么用org.hibernate.type.BinaryType的API类实例代码及写法,或者点击链接到github查看源代码。
public Type getType() throws MappingException {
if ( type != null ) {
return type;
}
if ( typeName == null ) {
throw new MappingException( "No type name" );
}
if ( typeParameters != null
&& Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_DYNAMIC ) )
&& typeParameters.get( DynamicParameterizedType.PARAMETER_TYPE ) == null ) {
createParameterImpl();
}
Type result = getMetadata().getTypeConfiguration().getTypeResolver().heuristicType( typeName, typeParameters );
// if this is a byte[] version/timestamp, then we need to use RowVersionType
// instead of BinaryType (HHH-10413)
if ( isVersion && BinaryType.class.isInstance( result ) ) {
log.debug( "version is BinaryType; changing to RowVersionType" );
result = RowVersionType.INSTANCE;
}
if ( result == null ) {
String msg = "Could not determine type for: " + typeName;
if ( table != null ) {
msg += ", at table: " + table.getName();
}
if ( columns != null && columns.size() > 0 ) {
msg += ", for columns: " + columns;
}
throw new MappingException( msg );
}
return result;
}
boolean hasBlob() {
for (String property: iMeta.getPropertyNames()) {
if (iMeta.getPropertyType(property) instanceof BinaryType) return true;
}
return false;
}
/**
* Bind a positional binary-valued parameter.
*
* @param position The parameter position
* @param val The bind value
*
* @return {@code this}, for method chaining
*
* @deprecated (since 5.2) use {@link #setParameter(int, Object)} or {@link #setParameter(int, Object, Type)}
* instead
*/
@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBinary(int position, byte[] val) {
setParameter( position, val, BinaryType.INSTANCE );
return this;
}
/**
* Bind a named binary-valued parameter.
*
* @param name The parameter name
* @param val The bind value
*
* @return {@code this}, for method chaining
*
* @deprecated (since 5.2) use {@link #setParameter(int, Object)} or {@link #setParameter(int, Object, Type)}
* instead
*/
@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBinary(String name, byte[] val) {
setParameter( name, val, BinaryType.INSTANCE );
return this;
}
/**
* Bind a positional binary-valued parameter.
*
* @param position The parameter position
* @param val The bind value
*
* @return {@code this}, for method chaining
*
* @deprecated (since 5.2) use {@link #setParameter(int, Object)} or {@link #setParameter(int, Object, Type)}
* instead
*/
@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBinary(int position, byte[] val) {
setParameter( position, val, BinaryType.INSTANCE );
return this;
}
/**
* Bind a named binary-valued parameter.
*
* @param name The parameter name
* @param val The bind value
*
* @return {@code this}, for method chaining
*
* @deprecated (since 5.2) use {@link #setParameter(String, Object)} or {@link #setParameter(String, Object, Type)}
* instead
*/
@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setBinary(String name, byte[] val) {
setParameter( name, val, BinaryType.INSTANCE );
return this;
}