I am working with a postgres 10.13 , Spring boot starter 2.27 and hibernate-core-5.4.15 versions. recently I had to use a native query with several joins to pull out set of UUIDs. it did not worked out and got "No Dialect mapping for JDBC type: 1111" error. I checked with a simple select query as follows and still am getting the same error. Can you please let me know a clue what will cause this error? this will work for normal tables and since in this case I need to query the table annotated with "@IdClass".
Entity Class -
@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "book")
@Audited
@AuditOverride(forClass = UpdatableEntity.class)
public class Book extends UpdatableEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@org.hibernate.annotations.Generated(value = GenerationTime.INSERT)
@org.hibernate.annotations.Type(type = "pg-uuid")
private UUID id;
private UUID bookOwner;
private String commennts;
private int rating;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy = "book", cascade = CascadeType.ALL, orphanRemoval = true)
private List<BookResource> resources = new ArrayList<>();
}
Mapping Id class -
@Builder
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "book_resource")
@IdClass(BookResourceIdClass.class)
@Audited
@AuditOverride(forClass = UpdatableEntity.class)
public class BookResource extends UpdatableEntity {
@Id private UUID book;
@Id private UUID resource;
}
ID class -
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BookResourceIdClass implements Serializable {
@Id private UUID book;
@Id private UUID resource;
}
JPA Repository class
@Repository
public interface BookRepository extends JpaRepository<Book, UUID> {
@Query(value = "select aa.book "
+ " from book_resource aa where aa.resource = :resource", nativeQuery = true)
List<UUID> findBook(@Param("resource") UUID resource);
}
Error -
Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111
at org.hibernate.dialect.TypeNames.get(TypeNames.java:71)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:103)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:706)
at org.hibernate.loader.custom.JdbcResultMetadata.getHibernateType(JdbcResultMetadata.java:100)
at org.hibernate.loader.custom.ScalarResultColumnProcessor.performDiscovery(ScalarResultColumnProcessor.java:45)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:494)
at org.hibernate.loader.Loader.processResultSet(Loader.java:2338)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2294)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2050)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2012)
at org.hibernate.loader.Loader.doQuery(Loader.java:953)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
at org.hibernate.loader.Loader.doList(Loader.java:2838)
at org.hibernate.loader.Loader.doList(Loader.java:2820)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2652)
at org.hibernate.loader.Loader.list(Loader.java:2647)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338)
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2131)
at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1163)
at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:173)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1533)
at org.hibernate.query.Query.getResultList(Query.java:165)
at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:126)
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:618)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:605)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
Highly appreciate your thoughts regarding this. Thanks in advance.