最佳方法将Cassandra ResultSet转换为Java对象在OSS驱动程序中

huangapple go评论151阅读模式
英文:

Best way to convert Cassandra ResultSet to java objects in OSS driver

问题

我们正在从Cassandra DSE迁移到OSS驱动程序的过程中,痛点是将结果集转换为Java对象列表。我不想使用Mapper注解,详细信息请参考这里

那么,将ResultSet转换为Java对象列表的最高效方式是什么?任何建议都会非常感激。

英文:

We are in the process of migrating from Cassandra DSE to OSS driver and the pain point is converting the result set into a list of Java objects. I don't want to use Mapper annotation, like detailed here

So what is the most efficient way to convert ResultSet into list of java objects? Any suggestion highly appreciated

答案1

得分: 1

如果您不想使用Mapper,只需编写一个转换函数,该函数将接受Row,提取所有必要的列,并返回从提取的数据构建的POJO...我看不到其他方法,除非编写一个特定版本的对象映射器,该映射器将使用反射来匹配POJO的字段名称与列名称。

英文:

If you don't want to use Mapper then just need to write converting function that will take Row, extract all necessary columns, and return POJO constructed from teh extracted data... I don't see other ways, except writing an adhoc version of object mapper that would use the reflection to match POJO's field names with the column names

huangapple
  • 本文由 发表于 2020年8月5日 04:59:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/63254955.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定