Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

hibernate - No Dialect mapping for JDBC type: 2003

Though there are some question exists with this title , but my query does not solve from those thread.

I am executing recursive (using with clause) query through hibernate in postgres, query's result contains path of search also

ex: one row of query result

5811;"axyz_3_3";"ABC";5782;5811;5797;4;"**{acl_3_3,acl3_4,acl3,acl_3_3}**";t;t

Does hibernate has any mapping type for "{acl_3_3,acl3_4,acl3,acl_3_3}" other than String, something similar to CHARACTER_ARRAY or CHAR_ARRAY.

Below is the sample of the query's output

id   |name|discri|pId|asscID|immeId|depth|path|cycle|canDelete
5797;"abc3";"abc";5782;5811;5788;7;"{abc_3_3,abc3_4,abc3,abc4}";t;f
5797;"abc3";"abc";5782;5786;5813;6;"{abc1,abc2,abc3,abc3}";t;f
5799;"abc4";"abc";5782;5811;5786;6;"{abc_3_3,abc3_4,abc4}";t;f
5788;"abc2";"abc";5782;5811;5786;6;"{abc_3_3,abc3_4,abc2}";f;f
5786;"abc1";"abc";5782;5786;5799;5;"{abc1,abc2,abc3,abc1}";t;f
5797;"abc3";"abc";5782;5786;5813;5;"{abc1,abc2,abc3,abc3}";t;f
5813;"abc3_4";"abc";5782;5786;5811;5;"{abc1,abc2,abc3_4}";f;f
5786;"abc1";"abc";5782;5811;5799;5;"{abc_3_3,abc4,abc1}";f;f
5813;"abc3_4";"abc";5782;5811;5797;4;"{abc3_4,abc3,abc3_4}";t;f
5811;"abc_3_3";"abc";5782;5811;5797;4;"{abc_3_3,abc3,abc_3_3}";t;t
5799;"abc4";"abc";5782;5811;5797;4;"{abc3,abc4}";f;f

Hibernate is throwing below exception

Caused by: com.vik.prod.service.UnidentifiedException: No Dialect mapping for JDBC type: 2003
at com.vik.prod.service.ServiceExecutorUtils.execute(ServiceExecutorUtils.java:93)
at com.vik.prod.service.ServerServiceExecutor.execute(ServerServiceExecutor.java:76)
at com.vik.prod.service.ClientDelegate.execute(ClientDelegate.java:197)
... 33 more

Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: 2003

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is how I have solved the issue in SpringBoot:

  1. Add dependency to pom.xml:
        <dependency>
            <groupId>com.vladmihalcea</groupId>
            <artifactId>hibernate-types-52</artifactId>
            <version>2.11.1</version>
        </dependency>
  1. Extend your Hybernate Dialect as follows:
import com.vladmihalcea.hibernate.type.array.StringArrayType;
import org.hibernate.dialect.PostgreSQL94Dialect;

public class PostgreSQL94CustomDialect extends PostgreSQL94Dialect {

    public PostgreSQL94CustomDialect() {
        super();
        this.registerHibernateType(2003, StringArrayType.class.getName());
    }

}
  1. Specify the PostgreSQL94CustomDialect in application.properties:
spring.jpa.properties.hibernate.dialect=com.package.name.PostgreSQL94CustomDialect

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...