For example, I have database with table book (id, title, themeId, authorId), table author (id, name) and table theme (id, name). I dont know, should i create entity exactly like in database (and then i will have problems with join queries):
class Book {
private id;
String title;
int bookThemeId;
int bookAuthorId;
}
or create something like this:
class Book {
private id;
String title;
BookTheme bookTheme;
Author bookAuthor;
}
in second case i will have problems if authorId or themeId is null (it may be) and problems with getting from DAO in general, if i want get only books list (problems - fields is null, and very bulky builder for Book entity).