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

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
}
@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
public interface UserRepository extends JpaRepository<User, Long> {

@Query(value = "SELECT DISTINCT unnest(u.roles)::text FROM User u", nativeQuery = true)
List<String> findDistinctRoles();
}
public 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?
11 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @direct_x_34! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
direct_x_34
direct_x_34OP10mo ago
I shared the exception. Nested exception Dialect mapping for JDBC. The value of the column is {roles1, roles2, roles3}
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
direct_x_34
direct_x_34OP10mo ago
@imp_o_rt Can you help me if you have any idea ?
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
direct_x_34
direct_x_34OP10mo ago
exception Dialect mapping for JDBC type? @imp_o_rt
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
direct_x_34
direct_x_34OP10mo ago
@Query(value = "SELECT DISTINCT unnest(u.roles)::text FROM User u", nativeQuery = true) List<String> findDistinctRoles(); This part throw error. My problem is there.
JavaBot
JavaBot10mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server