Hi Here's the HQL version, I don't really use Criteria so I can't tell how it'll be at point b)
select a.ResourceKey, a.CultureName, a.ResourceSet, a.ResourceValue as defaultText, b.ResourceValue from Localization a, Localization b where a.id = b.id and a.resourceSet='blacklist/edit' and (a.cultureName='' or a.cultureName='en') I don't know if you can use join between 2 "root" entities like in SQL, I've tried that, it doesn't work, but maybe I dont know the exact HQL syntax... My version of HQL works because you use inner join, but that raised me a question as your query will return the same result as: select a.resourceKey, a.cultureName, a.resourceSet, a.resourceValue as defaultText, a.resourceValue from localizations a where a.resourceSet='blacklist/edit' and (a.cultureName='' or a.cultureName='en') so no join needed. You maybe wanted to use a left join on a similar problem? On Jan 19, 5:44 pm, spiralni <[email protected]> wrote: > Hello, > > I have a table with this definition: > > [localizations] > + id > + resourceKey > + resourceValue > + cultureName > > My class is as follows > > public class Localization{ > public int Id { get; set; } > > public string ResourceKey { get; set; } > > public string ResourceValue { get; set; } > > public string ResourceSet { get; set; } > > public string CultureName { get; set; } > > public string DefaultResourceValue{ get; set; } > > } > > Please note the DefaultResourceValue property which is not related to > any field in the database. > > What I want is to execute this query (SQL as is) > > select a.resourceKey, a.cultureName, a.resourceSet, a.resourceValue > as > defaultText, b.resourceValue > from localizations a join localizations b on a.id = b.id > where a.resourceSet='blacklist/edit' and (a.cultureName='' or > a.cultureName='en') > > I want to know how can I write that sql statement in: > > a) HQL > b) using Criteria > > Hope you can help me.. regards > > p.s sorry for cross-posting this -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
