0

I have a query like this:

with t1 as
( select c.id cv_id, age(end_date, start_date) experience_year from cv c 
join candidate ca on c.candidate_id = ca.id 
left join work_experience we on c.id = we.cv_id 
left join major_level ml on c.id = ml.cv_id 
where (ca.address like concat('%',:candidateAddress,'%') or :candidateAddress is null or :candidateAddress = '') 
and ml.major_id in (select m.id from major m where m.major_name like concat('%',:techStack,'%'))) 
select t1.cv_id cvId, sum(experience_year) sumExperienceYear from t1  
group by cv_id 
having ((extract(year from sum(experience_year))) < :experienceYearSearch1 and :experienceOption = 1) 
or ((extract(year from sum(experience_year))) >= :experienceYearSearch1   
and (extract(year from sum(experience_year))) < :experienceYearSearch2 and :experienceOption = 2) 
or ((extract(year from sum(experience_year))) >= :experienceYearSearch2 and :experienceOption = 3) 
or :experienceOption = 0

I use Java8 and my properties like this:

spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

This is my Entity:

@Getter
@Setter
@Entity
@Table(name = "cv")
@AllArgsConstructor
@NoArgsConstructor
public class CV {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    @Column(name = "summary")
    private String summary;
}

Finally, I got the error code:

org.springframework.orm.jpa.JpaSystemException: No Dialect mapping for JDBC type: 1111; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
namkellbi
  • 75
  • 1
  • 2
  • 9
  • Try to use : `org.hibernate.dialect.PostgreSQL82Dialect` instead of `org.hibernate.dialect.PostgreSQLDialect` – Quentin Genet Aug 03 '22 at 08:24
  • @QuentinGenet: does hibernate really not support a more recent (and supported) Postgres version? –  Aug 03 '22 at 08:27
  • it doesn't working – namkellbi Aug 03 '22 at 08:28
  • PostgreSQL 13.7 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, 64-bit – namkellbi Aug 03 '22 at 08:30
  • Can you show from your application.properties your drivers JDBC line please ? – Quentin Genet Aug 03 '22 at 08:32
  • I dont know drivers JDBC config. Can you guide me ? – namkellbi Aug 03 '22 at 08:38
  • 1
    Related, possibly duplicate: [No Dialect mapping for JDBC type: 1111](https://stackoverflow.com/questions/28192547/no-dialect-mapping-for-jdbc-type-1111). 1111 is Types.OTHER, so please provide the PostgreSQL column types involved in the query (e.g. by providing us the DDL). – Mark Rotteveel Aug 03 '22 at 08:52
  • 1
    Have you tried removing the `spring.jpa.database-platform` property? This will let hibernate select the most appropriate dialect for the database (at least in the most recent versions). Else check the duplicate as mentioned earlier. – M. Deinum Aug 03 '22 at 09:45

1 Answers1

0
org.hibernate.dialect.PostgreSQLDialect 

is deprecated.

Try to use

 org.hibernate.dialect.PostgreSQL10Dialect

instead the deprecated version. Maybe you should change version with your PostgreSQL version... You should use the dialect that best matches the PostgreSQL JDBC driver you are using.

Have you a jdbc driver dependency in your pom.xml like that ? If there is not? After adding the JDBC driver update your maven project.

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.4.0</version>
</dependency>

And then in your application properties you must have this line :

spring.datasource.driver-class-name=org.postgresql.jdbc.Driver

Try it please to see if there is a better result. You can have a look on this good tutorial here.

Quentin Genet
  • 155
  • 2
  • 3
  • 15