Class is defined as this:
class User {
public int ID { get; set; }
public string OpenID { get; set; }
public IList<Tag> Tags { get; set; }
}
OpenID is set as natural-id, so that the second level cache recognizes this.
I have this HQL query which returns a list of user tags.
db.CreateQuery("select Tags from User where OpenID = :openId")
.SetString("openId", openId)
.List<Tag>();
As far as I know HQL does not have a syntax to identify OpenID as natural-id, but CriteriaQuery has that (Restrictions.NaturalId()...)
So I need to convert this query to CriteriaQuery. Something in this direction:
db.CreateCriteria<User>()
.Add(Restrictions.NaturalId().Set("OpenID", openId))
//I need to tell criteria query that I want to return Tags property here - I don't know how to do that
.List<Tag>();