【发布时间】:2019-08-10 12:47:03
【问题描述】:
我使用spring-data-jpa与spring boot和postgreSql进行对象关系映射,并编写了自定义方法来获取task_id列与where条件匹配时的不同值
@Query(value = "select distinct task_id from schema_task_test.test_table where type =:type", nativeQuery = true)
public List<Integer> findDistinctTasks(@Param("type") String type);
但在数据库中 type 是 Enum 类型,所以我得到了执行
错误
[ERROR] 2019-03-19 16:33:45,006 http-nio-8080-exec-1 org.hibernate.engine.jdbc.spi.SqlExceptionHelper - {} - ERROR: operator does not exist: schema_task_test.type_enum = character varying
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
【问题讨论】:
-
可以添加实体类吗?
-
没有实体@mohammad_1m2这可能吗
-
原生查询是另一个可以在没有实体的情况下使用的选项。
标签: java postgresql spring-boot spring-data-jpa