com.vladmihalcea.hibernate.type.basic.PostgreSQLCITextType 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.basic;
import com.vladmihalcea.hibernate.type.ImmutableType;
import com.vladmihalcea.hibernate.type.util.Configuration;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
/**
* Maps a {@link String} object type to a PostgreSQL citext
* column type.
*
* @author Sergei Portnov
*/
public class PostgreSQLCITextType extends ImmutableType {
public static final PostgreSQLCITextType INSTANCE = new PostgreSQLCITextType();
public PostgreSQLCITextType() {
super(String.class);
}
public PostgreSQLCITextType(org.hibernate.type.spi.TypeBootstrapContext typeBootstrapContext) {
super(String.class, new Configuration(typeBootstrapContext.getConfigurationSettings()));
}
@Override
public int getSqlType() {
return Types.OTHER;
}
@Override
protected String get(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
Object value = rs.getObject(position);
return value == null ? null : value.toString();
}
@Override
protected void set(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) throws SQLException {
st.setObject(index, value, Types.OTHER);
}
}