com.vladmihalcea.hibernate.type.array.DecimalArrayType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-types-60 Show documentation
Show all versions of hibernate-types-60 Show documentation
Hibernate ORM 6.0 extra Types
package com.vladmihalcea.hibernate.type.array;
import com.vladmihalcea.hibernate.type.array.internal.AbstractArrayType;
import com.vladmihalcea.hibernate.type.array.internal.DecimalArrayTypeDescriptor;
import com.vladmihalcea.hibernate.type.util.Configuration;
import com.vladmihalcea.hibernate.type.util.ParameterizedParameterType;
import org.hibernate.usertype.DynamicParameterizedType;
import java.math.BigDecimal;
import java.util.Properties;
/**
* Maps a {@code decimal[]} array on a PostgreSQL ARRAY column type.
* For more details about how to use it, check out this article.
*
* @author Moritz Kobel
*/
public class DecimalArrayType extends AbstractArrayType {
public static final DecimalArrayType INSTANCE = new DecimalArrayType();
public DecimalArrayType() {
super(
new DecimalArrayTypeDescriptor()
);
}
public DecimalArrayType(Configuration configuration) {
super(
new DecimalArrayTypeDescriptor(),
configuration
);
}
public DecimalArrayType(Class arrayClass) {
this();
Properties parameters = new Properties();
parameters.put(DynamicParameterizedType.PARAMETER_TYPE, new ParameterizedParameterType(arrayClass));
setParameterValues(parameters);
}
public DecimalArrayType(org.hibernate.type.spi.TypeBootstrapContext typeBootstrapContext) {
this(new Configuration(typeBootstrapContext.getConfigurationSettings()));
}
public String getName() {
return "decimal-array";
}
}