简体   繁体   English

java中内部联接的解析结果[性能相关]

[英]Parsing result of inner join in java [Performance Related]

So I am currently in an issue regarding joins. 所以我目前在有关联接的问题上。 I have 4 tables that I "left join" together. 我有4个“左连接”在一起的表。 My Question here is the following: If I select all the rows from the resulting join how will I be able to parse the information into java code? 我的问题如下:如果我从结果联接中选择所有行,如何将信息解析为Java代码?

For the sake of an example let's say we have the following table: 为了举例,我们有下表:

Persons
ID | NAME
1 | Tim
2 | Matthew

And

Cellphones
PK_ID | PERSON_ID | NUMBER
1 | 1 | +81037101
2 | 1 | +81911132
3 | 2 | +6182928191

Let's say we want to join the result and obtain all the information about our clients. 假设我们要加入结果并获取有关客户的所有信息。 How will I parse the information in java giving I have a class Person which has an ArrayList? 给定我有一个具有ArrayList的Person类,我将如何解析java中的信息? How could I parse all the numbers that Tim has if I have a multiple row result from the inner join? 如果我从内部联接中得到多行结果,该如何解析蒂姆拥有的所有数字? What is the best way to parse the cellphones of all the "Persons"? 解析所有“人员”手机的最佳方法是什么? SQL-Logic with group_concat, then a split in java, or SQL pure row fetch then parsing them in java? 带有group_concat的SQL逻辑,然后在Java中拆分,还是在SQL中纯SQL提取行然后在Java中解析它们? Which is better as performance? 哪个表现更好?

In your case, to be able to load all the phone numbers of Tim using one query, i recommend you to use Hibernate Framework, Create and annotate you entities, and with a simple JPQL query you can retrieve all tha data for a given person without taking too much care about the query and how to store the data into you entites. 在您的情况下,为了能够使用一个查询加载Tim的所有电话号码,我建议您使用Hibernate Framework,创建并注释实体,并且通过简单的JPQL查询,您可以检索给定人员的所有tha数据而无需对查询以及如何将数据存储到实体中非常注意。 Also I recommend Hibernate for a better performance. 我也建议使用Hibernate以获得更好的性能。 Good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM