Quote:
So go use the @OneToOne on Blog entity. What's the problem? Now when you do that, you just have to update the post in blob (blog?) entity whenever there is a latest post.
The problem is that this is not an option. I provided this as a sample model. The actual model I am working with doesn't deal with Blogs and Posts. Sorry for the obfuscation, but I was attempting to keep it simple.
Regardless, the real issue is that I need Hibernate to be aware of how this property is derived. If Hibernate is aware of it via a JPA/Hibernat annotation, then I can use that property in Criteria queries to order a collection of "Blogs" by their latest Posts. Also, I would be able to query all Blogs with a latest posting date of XYZ. Finally, I wouldn't have to load the entire collection to find the latest posting.
I suppose I could use JPQL to do all of this, but it would be an exception to my framework that I would like to avoid. Currently, the framework doesn't have any special use cases coded within it. It only deals with requests to sort and filter based on property names alone, which are provided to a Criteria for Hibernate to digest. With this in mind, I can't do:
Code:
postings.get(0);
I appreciate the input and welcome any other ideas.
****UPDATE****
It turns out that max(id) will not guarantee me the lastest posting. I actually have to retrieve it by a date field on the post (e.g. max(postDate) )