1 package com.vladmihalcea.hibernate.type.basic;
2
3 import com.vladmihalcea.hibernate.type.ImmutableType;
4 import org.hibernate.engine.spi.SharedSessionContractImplementor;
5
6 import java.sql.PreparedStatement;
7 import java.sql.ResultSet;
8 import java.sql.SQLException;
9 import java.sql.Types;
10
11
17 public class PostgreSQLCITextType extends ImmutableType<String> {
18
19 public static final PostgreSQLCITextType INSTANCE = new PostgreSQLCITextType();
20
21 public PostgreSQLCITextType() {
22 super(String.class);
23 }
24
25 @Override
26 public int[] sqlTypes() {
27 return new int[]{Types.OTHER};
28 }
29
30 @Override
31 protected String get(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException {
32 Object value = rs.getObject(names[0]);
33 return value == null ? null : value.toString();
34 }
35
36 @Override
37 protected void set(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) throws SQLException {
38 st.setObject(index, value, Types.OTHER);
39 }
40 }
41