• Post Reply Bookmark Topic Watch Topic
  • New Topic

Join ArrayLists  RSS feed

 
nu nin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll do my best to explaining this example, if something it's not clear, just let me know. Thank you

I have a Table called Register into a Database that has some of this fields: Name, Last Name, Adress, Country, Language. I just want to use some of those fields like: Name, Country & language.

And the other Table is called Continent has this fields: Name, Passport_Num, Continent, Visa. I just want to use Continent & Visa (As you can see the table Register & Contient has the "Name" field in common)



What i want to do, is to put together both lists with the query results without repeating results from both tables with same fields of each one show in the example like this:



And with just one field of the Continent list.





Ps. Using only the lists shown.

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your data is from the database right? Why not doing the join in SQL and fetch that result to your list?
 
nu nin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Your data is from the database right? Why not doing the join in SQL and fetch that result to your list?



Because in reallity it's more complex than this simple example and i have done behind those list there exist more queries than can't be modified, those queries show me the result of result, there are like 3 queries behind..
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK given you have to use lists to get your desired result, then by "joining" I don't think you meant append or union.

If I understand you correctly, you are trying to transform the 2 lists to get a new list (your desired one). If so you may want to look into Apache commons ListUtils.transformList method. Or ListUtils in general to see if those methods are any use.
 
nu nin
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:OK given you have to use lists to get your desired result, then by "joining" I don't think you meant append or union.

If I understand you correctly, you are trying to transform the 2 lists to get a new list (your desired one). If so you may want to look into Apache commons ListUtils.transformList method. Or ListUtils in general to see if those methods are any use.



OK thank you, i was wondering about there's not way using java as it's, without apache?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!