相关文章推荐
个性的小马驹  ·  Docker安装Zookeeper教程(超详 ...·  1 年前    · 
不羁的山羊  ·  在Python中释放内存的简单方法·  1 年前    · 
悲伤的野马  ·  css图片居中(水平居中和垂直居中) - ...·  2 年前    · 
骑白马的紫菜汤  ·  Excel生成不重复id或者相同的列_exc ...·  2 年前    · 
Code  ›  Hello friends may anybody help me about custom Query using J kotlinlang #spring
https://slack-chats.kotlinlang.org/t/479750/hello-friends-may-anybody-help-me-about-custom-query-using-j
大鼻子的枕头
6 月前
https://kotlinlang.org logo
Join Slack
Powered by
Hello friends, may anybody help me about custom Qu...
# spring
o

Okan Yıldırım

05/17/2022, 10:50 AM
Hello friends, may anybody help me about custom Query using JpaRepository ? I do use this query:
Copy code
@Query("select id, email from User")
fun getAllIdsAndEmails(): List<Pair<Long, String>>
But sadly I get an error of
No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [kotlin.Pair<?, ?>]

Okan Yıldırım

05/17/2022, 10:51 AM
Also tried
List<Tuple>
, still did not work

Okan Yıldırım

05/17/2022, 10:52 AM
But the return type is like Pair this is example return [ [ 0, “ x@gmail.com ” ], [ 1, “ a@mail.com ” ] ]
g

Gabriel Pomin

05/17/2022, 11:32 AM
Have you tried
List<User>
?
o

Okan Yıldırım

05/17/2022, 3:29 PM
let me do it

Okan Yıldırım

05/17/2022, 3:30 PM
but I am not selecting all required fields of user

Okan Yıldırım

05/17/2022, 3:31 PM
Yeah it gave error
g

Gabriel Pomin

05/17/2022, 3:42 PM
Have you tried something like this, using some list implementation:
fun getAllIdsAndEmails(): List<Long, String>
? Or, you could use something like they show here: https://faun.pub/select-specific-columns-from-a-database-table-using-spring-data-jpa-d4eb0a24a2c4 That it is similar to what I see in a Stack overflow thread
 
推荐文章
个性的小马驹  ·  Docker安装Zookeeper教程(超详细)_docker 安装zk-CSDN博客
1 年前
不羁的山羊  ·  在Python中释放内存的简单方法
1 年前
悲伤的野马  ·  css图片居中(水平居中和垂直居中) - Yiven - 博客园
2 年前
骑白马的紫菜汤  ·  Excel生成不重复id或者相同的列_excel id_《Hulen》的博客-CSDN博客
2 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号