I'm using Postgres with a custom type extension (visible as Type.OTHER), and I want to be able to utilise the type without casting in native queries. My Java type is EmbVector, and my custom type is PostgresVectorCol2Type, both of which implement UserType. My Postgres entity is defined as follows:
And I believe my @TypeDef should be sufficient to allow suitable types to be selected for embedding without the need for further @Type annotation. The final piece of the jigsaw is ostensibly a Postgrest dialect implementation:@TypeDef( name = "vector", defaultForType = EmbVector::class, typeClass = PostgresVectorCol2Type::class ) @Entity @Table(name = "items") class EmbeddingRecord { @Id @GeneratedValue(strategy = GenerationType.AUTO) var id: Long = 0 @Column @Type(type = "vector") lateinit var embedding: EmbVector @Column lateinit var label: String }
properties registered in application:public class VectorPostgreDialect extends PostgreSQL10Dialect { public VectorPostgreDialect() { //this.registerColumnType(Types.OTHER, "vector"); registerHibernateType(Types.OTHER, EmbVector.class.getName()); } }
All of this, however, ends spectacularly in the end with:spring.jpa.properties.hibernate.dialect.config=pl.qus.maxvector.hibernate.customtypes.VectorPostgreDialect
The web article that I read is fairly limited and typically states that the actions listed above are sufficient. Is there something I'm missing?org.hibernate.HibernateException: Could not determine a type for class: pl.qus.maxvector.model.EmbVector at org.hibernate.internal.SessionFactoryImpl.resolveParameterBindType(SessionFactoryImpl.java:1129) at org.hibernate.internal.SessionFactoryImpl.resolveParameterBindType(SessionFactoryImpl.java:1112) at org.hibernate.query.internal.QueryParameterBindingImpl.bindValue(QueryParameterBindingImpl.java:85) at org.hibernate.query.internal.QueryParameterBindingImpl.setBindValue(QueryParameterBindingImpl.java:57) at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:501) at org.hibernate.query.internal.NativeQueryImpl.setParameter(NativeQueryImpl.java:650) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:410) at com.sun.proxy.$Proxy108.setParameter(Unknown Source) at pl.qus.maxvector.dao.PostgresVectorDAOImpl.selectClosest(PostgresVectorDAOImpl.kt:95)