com.vladmihalcea.hibernate.type.array.TimestampArrayType 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.TimestampArrayTypeDescriptor;
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 timestamp[] 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 TimestampArrayType extends AbstractArrayType {
public static final TimestampArrayType INSTANCE = new TimestampArrayType();
public TimestampArrayType() {
super(
new TimestampArrayTypeDescriptor()
);
}
public TimestampArrayType(Configuration configuration) {
super(
new TimestampArrayTypeDescriptor(), configuration
);
}
public TimestampArrayType(Class arrayClass) {
this();
Properties parameters = new Properties();
parameters.put(DynamicParameterizedType.PARAMETER_TYPE, new ParameterizedParameterType(arrayClass));
setParameterValues(parameters);
}
public TimestampArrayType(org.hibernate.type.spi.TypeBootstrapContext typeBootstrapContext) {
this(new Configuration(typeBootstrapContext.getConfigurationSettings()));
}
public String getName() {
return "timestamp-array";
}
}