hi everyone,
here is what I want to do I have two table on my data base
Book(bookId,bookTitle,authorId)
Author(AuthorId,AuthorName)
I want to get list of books that have a particular author (identified by name)
here is what I thought of:
Code:
Criteria criteria=session.createCriteria(Author.class);
criteria.add(Restrictions.ilike("AuthorName", StringUtil.lowerCase("ABC")));
List lauthor=criteria.list();
Criteria criteriaB=session.createCriteria(Book.class);
for (int i = 0; i < lauthor.size(); i++)
{
Author ath = (Author)lauthor.get(i);
criteriaB.add(Restrictions.ilike("AuthorId", StringUtil.lowerCase(ath.getAuthorId())));
}
List lfinalB=criteriaB.list();
Is there a better solution??
thanks in advance.