com.vladmihalcea.hibernate.type.array.DateArrayType 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.DateArrayTypeDescriptor;
import com.vladmihalcea.hibernate.type.util.Configuration;
import com.vladmihalcea.hibernate.type.util.ParameterizedParameterType;
import org.hibernate.usertype.DynamicParameterizedType;
import java.util.Date;
import java.util.Properties;
/**
* Maps an {@code Date[]} array on a PostgreSQL date[] 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 Guillaume Briand
*/
public class DateArrayType extends AbstractArrayType {
public static final DateArrayType INSTANCE = new DateArrayType();
public DateArrayType() {
super(
new DateArrayTypeDescriptor()
);
}
public DateArrayType(Configuration configuration) {
super(
new DateArrayTypeDescriptor(), configuration
);
}
public DateArrayType(Class arrayClass) {
this();
Properties parameters = new Properties();
parameters.put(DynamicParameterizedType.PARAMETER_TYPE, new ParameterizedParameterType(arrayClass));
setParameterValues(parameters);
}
public DateArrayType(org.hibernate.type.spi.TypeBootstrapContext typeBootstrapContext) {
this(new Configuration(typeBootstrapContext.getConfigurationSettings()));
}
public String getName() {
return "date-array";
}
}