1
votes

I have a native query to select datafrom database, I'm using postgrsql, hibernate and spring boot with java ... I'm trying to find an user according to some criterias in where clause but i get the "No Dialect mapping for JDBC type: 1111" error caused by the json field, how can i overcome this error? and this is my code:

EntityManager em = entityManagerFactory.createEntityManager();
List<Object[]> resultat = new ArrayList<>();

String sqlString = "SELECT u.name, u.age, u.address, u.phone, u.activated FROM user as u ";

Query query = em.createNativeQuery(sqlString);
List<User> resultats = query.getResultList();
em.close();

the user entity has name is a text, age is a number, address is an address object and phone is a json object.

(for some reasons i need to clean the value of listOperators using regular expression and it works on posgrsql).

the dialect that I'm using in my application.properties is spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect

I will appreciate your help, thanks in advance.

1
Different RDBMS, I know, but similar Hibernate context: see here. Any help there? - andrewJames
Also looks like you are concatenating your SQL string - best to use a prepared statement. - andrewJames
@andrewjames thanks ... yes i saw it and i tried to cast the primary key to varchar and json object to text but i still have the same error. - Nick
@andrewjames the problem is in the request it self or somewhere? - Nick
I don't know. A suggestion: remove columns from your SQL statement, one-by-one, and re-test each time, until it works. If you remove them all and it still does not work, that tells you something, too. Sorry - that's all I got. - andrewJames

1 Answers

0
votes

Thanks to the @andrewjames indications, I resolved the issue by casting the json field to text