Class PostgreSQLVectorType

java.lang.Object
io.hypersistence.utils.hibernate.type.ImmutableType<float[]>
io.hypersistence.utils.hibernate.type.basic.PostgreSQLVectorType
All Implemented Interfaces:
Serializable, org.hibernate.type.Type, org.hibernate.usertype.EnhancedUserType<float[]>, org.hibernate.usertype.UserType<float[]>

public class PostgreSQLVectorType extends ImmutableType<float[]>
Maps a float[] object type to a PostgreSQL pgvector vector column type.

This implementation does not require the pgvector-java library on the classpath. Instead, it builds the underlying org.postgresql.util.PGobject via reflection, the same way PostgreSQLInetType and PostgreSQLMacAddressType do for other PostgreSQL-specific column types.

Author:
Chirag Gupta
See Also:
  • Field Details

  • Constructor Details

    • PostgreSQLVectorType

      public PostgreSQLVectorType()
    • PostgreSQLVectorType

      public PostgreSQLVectorType(org.hibernate.type.spi.TypeBootstrapContext typeBootstrapContext)
  • Method Details

    • getSqlType

      public int getSqlType()
    • get

      public float[] get(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) throws SQLException
      Description copied from class: ImmutableType
      Get the column value from the JDBC ResultSet.
      Specified by:
      get in class ImmutableType<float[]>
      Parameters:
      rs - JDBC ResultSet
      position - database column position
      session - current Hibernate Session
      owner - current Hibernate SessionFactoryImplementor
      Returns:
      column value
      Throws:
      SQLException - in case of failure
    • set

      public void set(PreparedStatement st, float[] value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws SQLException
      Description copied from class: ImmutableType
      Set the column value on the provided JDBC PreparedStatement.
      Specified by:
      set in class ImmutableType<float[]>
      Parameters:
      st - JDBC PreparedStatement
      value - database column value
      index - database column index
      session - current Hibernate Session
      Throws:
      SQLException - in case of failure
    • fromStringValue

      public float[] fromStringValue(CharSequence sequence) throws org.hibernate.HibernateException
      Throws:
      org.hibernate.HibernateException