com.vladmihalcea.hibernate.type.array.IntArrayType Maven / Gradle / Ivy
Show all versions of hibernate-types-60 Show documentation
package com.vladmihalcea.hibernate.type.array;
import com.vladmihalcea.hibernate.type.array.internal.AbstractArrayType;
import com.vladmihalcea.hibernate.type.array.internal.IntArrayTypeDescriptor;
import com.vladmihalcea.hibernate.type.util.Configuration;
import com.vladmihalcea.hibernate.type.util.ParameterizedParameterType;
import org.hibernate.usertype.DynamicParameterizedType;
import java.util.Properties;
/**
* Maps an {@code int[]} array on a PostgreSQL ARRAY type. Multidimensional arrays are supported as well, as explained in this article.
*
* For more details about how to use it, check out this article on vladmihalcea.com.
*
* @author Vlad Mihalcea
*/
public class IntArrayType extends AbstractArrayType {
public static final IntArrayType INSTANCE = new IntArrayType();
public IntArrayType() {
super(
new IntArrayTypeDescriptor()
);
}
public IntArrayType(Configuration configuration) {
super(
new IntArrayTypeDescriptor(), configuration
);
}
public IntArrayType(Class arrayClass) {
this();
Properties parameters = new Properties();
parameters.put(DynamicParameterizedType.PARAMETER_TYPE, new ParameterizedParameterType(arrayClass));
setParameterValues(parameters);
}
public IntArrayType(org.hibernate.type.spi.TypeBootstrapContext typeBootstrapContext) {
this(new Configuration(typeBootstrapContext.getConfigurationSettings()));
}
public String getName() {
return "int-array";
}
}