I'm trying to figure out if there's a way I can do the following strictly using Criteria and DetachedCriteria via a subquery or some other way that is more optimal. NameGuidDto is nothing more than a lightweight object that has string and Guid properties.
public IList<NameGuidDto> GetByManager(Employee manager)
{
// First, grab all ...
I have an entity A which HasMany entities B and entities C. All entities A, B and C have some references x,y and z which should be loaded eagerly.
I want to read from the database all entities A, and load the collections of B and C eagerly using criteria API.
So far, I am able to fetch the references in 'A' eagerly. But when the collec...
Consider the following Class structure...
public class ListViewControl
{
public int SystemId {get; set;}
public List<ControlAction> Actions {get; set;}
public List<ControlAction> ListViewActions {get; set;}
}
public class ControlAction
{
public string blahBlah {get; set;}
}
I want to load class ListViewControl eagerly...
I have tried to use Moq to unit test a method on a repository that uses the DetachedCriteria class. But I come up against a problem whereby I cannot actually mock the internal Criteria object that is built inside. Is there any way to mock detached criteria?
Test Method
[Test]
[Category("UnitTest")]
public void F...
In my db I store telephone numbers of things as input by the user (I want to let user decide how he format their phone number)
when users search for a phone number they most likely wont format the number in a way that I can just compare the two strings. Even 'like' wont do the trick since maybe the number has parenthesis or some other u...
Hi all.
I have the following query and I don't know how can I write it using criteria.
SELECT questions_cnt, COUNT(*) users_cnt
FROM (
SELECT COUNT(DISTINCT question) questions_cnt
FROM UserAnswer
GROUP BY user
) t
GROUP BY questions_cnt
I have started to write criteria query. It looks like the following
final DetachedC...
In my model I have an abstract "User" class, and multiple subclasses such as Applicant, HiringManager, and Interviewer. They are in a single table, and I have a single DAO to manage them all.
User:
@Entity
@Table(name="User")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="role",
discriminatorTy...
Hi,
I have the following SQL Query returning the results I need:
SELECT
Person.FirstName,Person.LastName,OrganisationUnit.Name AS UnitName, RS_SkillsArea.Name AS SkillsArea, Activity.Name AS ActivityName, Activity.CLASS, Activity.StartsOn, Activity.EndsOn,
SUM(ActivityCost.CostAmount) /
NULLIF(
(
SELECT COUNT(Registration.A...
I modeled all of my tables and already ported most of my queries using detached criteria's. All is working very well however I'm at a point where I don't know how to advance. I have a sub-query that uses Oracle's "connect by" clause. How do developers typically overcome that limitation of Castle/NHibernate?
I am using the latest version...
I'm fiddling with my repository class and attempted to execute a query with a detached criteria. However, it doesn't seem to like me setting the result transformer to a non AR-type.
public class IncidentRepository
{
public static IList<AuditReport> GetAllIncidentsToAudit()
{
DetachedCriteria dc = DetachedCriteria.For<Inc...
Is there any way that Criteria for qureies can be built on a remote (Swing/SWT etc) client? We've been using the DetachedCriteria functionality in Hibernate for quite some time, but would like to use standard JPA 2.
If not, could the code from hibernate be re-factored to create the remote API? Or is this something that might come alon...
this classes have some similar methods but seems to work slightly different. What's the difference of them and when should I use each of them?
...
Hi,
What is IDetachedQuery and its difference with DetachedCriteria? How and when IDetachedQuery is used?
UPDATE:
I'm using NHibernate 2.1.2.4000
...
Is it possible to create a anoynmous count with nhibernate?
The below query throws the exception "No column *".
I could of course add a column name, but I'd prefer not to, because if I do, I'll have to lookup column names for 95 tables...
NHibernate.Criterion.DetachedCriteria dcIsUniqueDomainname = NHibernate.Criterion.DetachedCriteria...