Suppose I have a Post class and a Tag class. The relationship between mail and tag is one-to-many. How do I write a Hibernate query to retrieve List of Post objects that have this tag?
public IList<Post> FindByTag(Tag tag)
{
IList<Post> posts;
using (ISession session = HibernateUtil.GetSessionFactory().OpenSession())
{
posts = session.CreateCriteria<Post>()
.Add(...)
.List<Post>();
}
return posts;
}
source
share