相关文章推荐
暴走的火锅  ·  谨防异端|《驳斥大卫欧华》·  3 月前    · 
英勇无比的核桃  ·  java运行时创建或修改类-JavaAgen ...·  1 年前    · 
一身肌肉的剪刀  ·  Amazon.com: COSTWAY ...·  1 年前    · 
打酱油的香槟  ·  中国石化“油气氢电服”转型走向纵深·  1 年前    · 
一身肌肉的菠萝  ·  杭州市部分行政区划优化调整·  1 年前    · 
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
大鼻子的枕头
8 月前
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
 
推荐文章
暴走的火锅  ·  谨防异端|《驳斥大卫欧华》
3 月前
英勇无比的核桃  ·  java运行时创建或修改类-JavaAgent-腾讯云开发者社区-腾讯云
1 年前
一身肌肉的剪刀  ·  Amazon.com: COSTWAY Deep Fryer with Basket, 5.3Qt Stainless Steel Electric Oil Fryer w/Adjustable Te
1 年前
打酱油的香槟  ·  中国石化“油气氢电服”转型走向纵深
1 年前
一身肌肉的菠萝  ·  杭州市部分行政区划优化调整
1 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号