I am trying to replace a working criteria query in a named query, and the syntax is not getting the rights HKL version Apparently wants both type and ID parameters specified
The query is more than a square mapped with any (below)
Is anyone correcting me with syntax Can one give a hand?
Cheers,
Berryl
Work criteria query result = _SESSION .CreateCriteria & LT; Allocation & gt; () .Add (Restrictions.Eq (propName_Resource, resources)) .Add (Restrictions.Between (PropName_starttime, (Date Time) searchRange.start, (Date Time) searchRange.End)) Kordr orders (orders. ASC (Pronam_ Starttaim )). List and lieutenant; Allocation & gt; (); To select as the this_.AllocationIf as Allocati1_2_0_, this_.ResourceType Resource2_2_0_, this_.ResourceId as ResourceId2_0_, Id2_0_ activity as the this_.ActivityType activity 4_2_0_, this_.ActivityId, this_.StartTime2_0_ start time, this_.EndTime as EndTime2_0_, where this_.PostingTime this_ fROM allocation as PostingT8_2_0_ this_.ResourceType = @ p0 and this_.ResourceId = @ p1 and this_ between @ P2 and P3 @ ordered by this_.StartTime ASC .StartTime; @ P0 = 'employee' [type: string (0)], @ p1 = 98304 [type: int 32 (0)], @ p2 = 3/14/2011 12:00:00 AM [type: date time (0 )], @ P3 = 3/20/2011 11:59:59 PM [Type: Date Time (0)] 2011-03-14 Som - 2011-03-20 Sun No mapping (which works!) & Lt; Meta-value value = "feature" class = "feature, ..." /> & Lt; Column name = "resource type" / & gt; & Lt; Column name = "resource id" / & gt; & Lt; / Any & gt; NAMED QUERY SO FAR (not working)
I thinks this is the HQL syntax but the error message says that Ultimate is missing .... Choose from an allocation where a.resource =: between resource and a.TimeRange.StartTime: Period: Start and Period: By a time limit. Starman .... back _session GetNamedQuery ("FetchByResourceForDateRange") .SetEntity ("Resource", Resource). SetDateTime ("periodStart", searchRange.Start) .SetDateTime ("periodEnd", searchRange.End) .List & LT; Allocation & gt; (); NHibernate.Exceptions.GenericADOException: Could not execute query [selection allocati1_2_, as the allocation0_2_, allocation0_. Resources as resources 2_2, allotment0_. ResourceId2_ as ResourceId, allocation0_. Type activity as activity 4_2_, allocation0_. Activated as active 2d_, allocation0_. Start time as starttime 2, allocation0_ EndTime2_, ordered by allocation0_.StartTime) allocation0_.StartTime between allocation PostingT8_2_ as allocation0_.PostingTime as eNDTIME allocation0_ where allocation0_.ResourceType=@p0 and allocation0_.ResourceId=@p1 and (@ p2 and @ p3] Name: Resources - Price : George Washington 000001 Name: Duration: Start: Value: 3/14/2011 12:00:00 AM Name: Duration Fact - Value: 3/20/2011 11:59:59 PM [SQL: Selection ... Allocation Allocation 0 Where allotment0_ ResourceType = @ p0 and allocation0_. ResourceId = @ p1 and (allocating0_. Initial time @ P2 and @ P3) order by allocation .0. Start-time] ----> Inadequate parameters provided for System.Data.SQLite.SQLiteException: SQLite error command UPDATE
This combination executes the wrong answer. It can not tell whether I have more or more than I ever needed
Select one from the allocation where a.resource.class =: class and a.resource.id =: id between a .TimeRange.StartTime: periodStart and: periodEnd ordered by a.TimeRange.StartTime back _session.GetNamedQuery ( "FetchByResourceForDateRange") .SetString ( "square", typeof (resource) .FullName) .SetInt32 ( "ID" , Resource.Id) .set time ("Periodart", search range. Start). Settate Time ("Periodend", Search Range.and). List and lieutenant; Allocation & gt; ();
OK, per Fabian maula, Leibung on NHI:
"You should not use your meta-data values type (unit)." Full name "
So in my case the following has worked in the previous HQL:
return _session.GetNamedQuery ( "FetchByResourceForDateRange") .SetString ( "class", "employee") .SetInt32 ( "ID", resource.Id) .SetDateTime ( "periodStart", searchRange.Start) .SetDateTime ( "periodEnd", SearchRange .End). List and lieutenant; Allocation & gt; (); I was hoping that a bit uglier than, but I'll take it: -)
hh,
beryl
result = _SESSION .CreateCriteria & LT; Allocation & gt; () .Add (Restrictions.Eq (propName_Resource, resources)) .Add (Restrictions.Between (PropName_starttime, (Date Time) searchRange.start, (Date Time) searchRange.End)) Kordr orders (orders. ASC (Pronam_ Starttaim )). List and lieutenant; Allocation & gt; (); To select as the this_.AllocationIf as Allocati1_2_0_, this_.ResourceType Resource2_2_0_, this_.ResourceId as ResourceId2_0_, Id2_0_ activity as the this_.ActivityType activity 4_2_0_, this_.ActivityId, this_.StartTime2_0_ start time, this_.EndTime as EndTime2_0_, where this_.PostingTime this_ fROM allocation as PostingT8_2_0_ this_.ResourceType = @ p0 and this_.ResourceId = @ p1 and this_ between @ P2 and P3 @ ordered by this_.StartTime ASC .StartTime; @ P0 = 'employee' [type: string (0)], @ p1 = 98304 [type: int 32 (0)], @ p2 = 3/14/2011 12:00:00 AM [type: date time (0 )], @ P3 = 3/20/2011 11:59:59 PM [Type: Date Time (0)] 2011-03-14 Som - 2011-03-20 Sun No mapping (which works!) & Lt; Meta-value value = "feature" class = "feature, ..." /> & Lt; Column name = "resource type" / & gt; & Lt; Column name = "resource id" / & gt; & Lt; / Any & gt; NAMED QUERY SO FAR (not working)
I thinks this is the HQL syntax but the error message says that Ultimate is missing .... Choose from an allocation where a.resource =: between resource and a.TimeRange.StartTime: Period: Start and Period: By a time limit. Starman .... back _session GetNamedQuery ("FetchByResourceForDateRange") .SetEntity ("Resource", Resource). SetDateTime ("periodStart", searchRange.Start) .SetDateTime ("periodEnd", searchRange.End) .List & LT; Allocation & gt; (); NHibernate.Exceptions.GenericADOException: Could not execute query [selection allocati1_2_, as the allocation0_2_, allocation0_. Resources as resources 2_2, allotment0_. ResourceId2_ as ResourceId, allocation0_. Type activity as activity 4_2_, allocation0_. Activated as active 2d_, allocation0_. Start time as starttime 2, allocation0_ EndTime2_, ordered by allocation0_.StartTime) allocation0_.StartTime between allocation PostingT8_2_ as allocation0_.PostingTime as eNDTIME allocation0_ where allocation0_.ResourceType=@p0 and allocation0_.ResourceId=@p1 and (@ p2 and @ p3] Name: Resources - Price : George Washington 000001 Name: Duration: Start: Value: 3/14/2011 12:00:00 AM Name: Duration Fact - Value: 3/20/2011 11:59:59 PM [SQL: Selection ... Allocation Allocation 0 Where allotment0_ ResourceType = @ p0 and allocation0_. ResourceId = @ p1 and (allocating0_. Initial time @ P2 and @ P3) order by allocation .0. Start-time] ----> Inadequate parameters provided for System.Data.SQLite.SQLiteException: SQLite error command UPDATE
This combination executes the wrong answer. It can not tell whether I have more or more than I ever needed
Select one from the allocation where a.resource.class =: class and a.resource.id =: id between a .TimeRange.StartTime: periodStart and: periodEnd ordered by a.TimeRange.StartTime back _session.GetNamedQuery ( "FetchByResourceForDateRange") .SetString ( "square", typeof (resource) .FullName) .SetInt32 ( "ID" , Resource.Id) .set time ("Periodart", search range. Start). Settate Time ("Periodend", Search Range.and). List and lieutenant; Allocation & gt; ();
OK, per Fabian maula, Leibung on NHI:
"You should not use your meta-data values type (unit)." Full name "
So in my case the following has worked in the previous HQL:
return _session.GetNamedQuery ( "FetchByResourceForDateRange") .SetString ( "class", "employee") .SetInt32 ( "ID", resource.Id) .SetDateTime ( "periodStart", searchRange.Start) .SetDateTime ( "periodEnd", SearchRange .End). List and lieutenant; Allocation & gt; (); I was hoping that a bit uglier than, but I'll take it: -)
hh,
beryl
Comments
Post a Comment