Hi All,
I have been sifting through pages on Google looking for the answer to no avail, however I think I am just phrasing the question incorrectly.
The scenario is as follows: I have an entity which users are able to either vote for or against. For arguments sake lets call the entity a business.
I would like to have a property on my business class which indicates how the currently logged on user voted for that particular business. i.e. I would like to show a green tick where the user for up and a red cross where the user voted down.
In SQL this is straight forward, I can create a SQL function which does this resolution based on a parameter ":userid" more specifically which can be passed into the proc. i.e.
SELECT
BusinessId,
CreatedOn,
Username,
[Content].ResolveBusinessVoteIndicator(:userid, P.BusinessId) AS VoteIndicator
FROM
Content.Business P
The main issue here is that I have to create an entity which maps to a stored procedure result. Which is bad because now I cannot use HQL or Criteria, which would be the methods of choice.
Another option would be to do the query and then simply iterate through the result and set that property, which would work if you were looking at one business at a time, but I need to display a large list of businesses at one time.
So I guess the question is... Is there way to map a property using either HQL or Criteria where that mapping is based on a formula which requires input at runtime? Similar to passing in parameters to a stored procedure and mapping out the results.