jcabi / jcabi-jdbc

Fluent Object-Oriented Wrapper of JDBC
https://jdbc.jcabi.com/
Other
104 stars 30 forks source link

Querying complex script with lots of join statement #52

Closed vkuchyn closed 7 years ago

vkuchyn commented 8 years ago

Hi The question is it possible to use this project for querying complex scripts where lots of joins. For example, I need to query books with authors (classic example) and map them to next structure

interface Book{
   List<Author> authors();
   String title();
}

interface Author {
  String name();
  String secondName();
}

interface Library {
   List<Book> books();
}

Here is my database. Suggest an author can write only one book for simplicity books

id title
1 Elegant Objects
2 Thinking in Java
3 Java Concurrency in Practice

authors

id name second_name book_fk
1 Egor Bugayenko 1
2 Bruce Eckel 2
3 Brian Goetz 3
4 Tim Peierls 3
5 Joshua Bloch 3
6 Joseph Bowbeer 3
7 David Holmes 3
8 Doug Lea 3

And next query

select * from books b join authors a on b.id = a.book_fk;

I would like to map next query to some implementation of interface Library

dmarkov commented 8 years ago

@yegor256 take a look at this issue please and dispatch it somehow, see par.21

yegor256 commented 8 years ago

@vkuchyn well, what the problem is exactly with? you just implement that selection in Library.books(). and then in each book you make new queries to retrieve authors. or I missed the point?

vkuchyn commented 8 years ago

@yegor256 I'd like to use join, because with subselect approach we breaks performance conditions

yegor256 commented 7 years ago

@vkuchyn I guess it's more a question about object-oriented programming and design than about this library specifically, right? Please post it to my blog, we'll discuss there. Here the ticket may be closed, I think.

vkuchyn commented 7 years ago

@yegor256 yes, you can close the ticket. Shall I post OOP/OOD question to proper topic as comment or there is an option to ask question, create topic, whatever at your blog? Thanks

yegor256 commented 7 years ago

@vkuchyn I would suggest to post it here: http://www.yegor256.com/2014/12/01/orm-offensive-anti-pattern.html Otherwise, you can join our Gitter chat and discuss it live with other OOP adepts: https://gitter.im/yegor256/elegantobjects Please, close the ticket (since you're the author of it), thanks