Coding Global Background
Coding Global

How to get array info from column in Spring Boot JPA (exception Dialect mapping for JDBC type Error)

Archived 2 years ago
2 messages
2 members
Created 2 years ago
Updated 2 years ago
Open in Discord
D
direct_x_34
Script Kiddie!
I have a problem to get ["role1","role2","role3"] from roles column.

Here is the entity shown below

@Entity
public class User {
    //...

    @Column(columnDefinition = "text[]")
    @Type(type = "com.baeldung.hibernate.arraymapping.CustomStringArrayType")
    private String[] roles;

    // getters and setters
}


Here is the JPARepository shown below
 interface UserRepository extends JpaRepository<User, Long> {

    @Query(value = "SELECT DISTINCT unnest(u.roles)::text FROM User u", nativeQuery = true)
    List<String> findDistinctRoles();
}


I got nested exception Dialect mapping for JDBC type?

How can I fix it?

Replies (2)