- Home
- LLBLGen Pro
- Bugs & Issues
TypeConverter
Joined: 21-May-2004
I have a field in a user table named "disabled". In SQL Server this is a bit field. In DB2 I have this as a smallint. I set a typeconverter to make it a boolean so I didn't have to change my business logic (We started off with SQL SERVER). Now here is the code that is throwing an error while using db2 (using the type converter).
bucket.PredicateExpression.AddWithAnd(PredicateFactory.CompareValue(UserFieldIndex.Disabled, ComparisonOperator.NotEqual, 1));
I was getting this error:
2006-03-08 11:21:22,062 [676] ERROR WebMissionFire.Login [] - at SD.LLBLGen.Pro.TypeConverters.BooleanNumericConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType)
at SD.LLBLGen.Pro.ORMSupportClasses.DbSpecificCreatorBase.GetRealValue(Object currentValue, TypeConverter typeConverterToUse, Type actualDotNetType)
at SD.LLBLGen.Pro.DQE.DB2.DB2SpecificCreator.CreateParameter(IEntityFieldCore field, IFieldPersistenceInfo persistenceInfo, ParameterDirection direction, Object valueToSet)
at SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareValuePredicate.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker, Boolean inHavingClause)
at SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression.ToQueryText(Int32& uniqueMarker)
at SD.LLBLGen.Pro.DQE.DB2.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Boolean relationsSpecified, Boolean sortClausesSpecified)
at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause)
at SD.LLBLGen.Pro.DQE.DB2.DynamicQueryEngine.CreatePagingSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.DynamicQueryEngineBase.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.CreateSelectDQ(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfoObjects, IPredicateExpression filter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedList(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedList(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates)
at MissionFire.BLL.ProcessEngine.ProcessEngineManager.GetAssignedProcess(Int32 projectId)
at WebMissionFire.Controls.RepWorkDistribution1.Load_Work_Distribution() in \\192.168.1.200\c$\WebMissionFire\Controls\RepWorkDistribution.ascx.cs:line 80
at WebMissionFire.Controls.RepWorkDistribution1.Page_Load(Object sender, EventArgs e) in \\192.168.1.200\c$\WebMissionFire\Controls\RepWorkDistribution.ascx.cs:line 48
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
I changed the code to this:
bucket.PredicateExpression.AddWithAnd(PredicateFactory.CompareValue(UserFieldIndex.Disabled, ComparisonOperator.NotEqual, true));
and now I get this error:
2006-03-08 11:31:34,031 [676] ERROR WebMissionFire.Login [] - **APPLICATION ERROR - ERROR [22005] [IBM] CLI0112E Error in assignment. SQLSTATE=22005**
2006-03-08 11:31:34,031 [676] ERROR WebMissionFire.Login [] - at IBM.Data.DB2.DB2Connection.b(IntPtr A_0, m A_1, x A_2)
at IBM.Data.DB2.DB2Command.a(CommandBehavior A_0, String A_1)
at IBM.Data.DB2.DB2Command.ExecuteReader(CommandBehavior behavior)
at IBM.Data.DB2.DB2Command.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteMultiRowDataTableRetrievalQuery(IRetrievalQuery queryToExecute, DbDataAdapter dataAdapterToUse, DataTable tableToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedList(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedList(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates)
at MissionFire.BLL.ProcessEngine.ProcessEngineManager.GetAssignedProcess(Int32 projectId) in c:\missionfiresource\missionfire\processengine\processenginemanager.cs:line 1167
at WebMissionFire.Controls.RepWorkDistribution1.Load_Work_Distribution() in \\192.168.1.200\c$\WebMissionFire\Controls\RepWorkDistribution.ascx.cs:line 80
at WebMissionFire.Controls.RepWorkDistribution1.Page_Load(Object sender, EventArgs e) in \\192.168.1.200\c$\WebMissionFire\Controls\RepWorkDistribution.ascx.cs:line 48
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
Reading the docs, it says: "This is completely transparent and very efficient: the application developer has no notice of the usage of the type converter other than perhaps compiling the generated code with the type converter assembly used as reference."
I have added the type converter as a ref as well, no luck.
WHat's the exception exactly? E.g. Nullreferenceexception... or something else? I see the stacktrace (thanks for that), but no exception name. As the exception occurs inside the type converter code, could you try with building the typeconverter code yourself (it's in the SDK) and reference that build instead in your project, and set a breakpoint in ConvertTo ? thanks
Joined: 21-May-2004
I put log4net support into it. What values did you want to see from ConvertTo?
Joined: 21-May-2004
2006-03-08 14:57:43,375 [2820] INFO SD.LLBLGen.Pro.TypeConverters.BooleanNumericConverter [] - ConvertTo() CALLED******************
2006-03-08 14:57:43,375 [2820] INFO SD.LLBLGen.Pro.TypeConverters.BooleanNumericConverter [] - Destination Type:: System.Int16
2006-03-08 14:57:43,375 [2820] INFO SD.LLBLGen.Pro.TypeConverters.BooleanNumericConverter [] - Value Type:: System.Boolean
Exception:
2006-03-08 14:57:43,390 [2820] ERROR MissionFire.BLL.ProcessEngine.ProcessEngineManager [] - ERROR [22005] [IBM] CLI0112E Error in assignment. SQLSTATE=22005
No, please state the type of hte exception, you'll get that as 'An exception of type 'Nullreferenceexception' has occured in ..' or similar.
If you follow my previous directions you should be able to step into the type converter and then check what the exception is and what causes it. could you report your findings please?
Joined: 21-May-2004
Otis wrote:
No, please state the type of hte exception, you'll get that as 'An exception of type 'Nullreferenceexception' has occured in ..' or similar.
If you follow my previous directions you should be able to step into the type converter and then check what the exception is and what causes it. could you report your findings please?
Sorry I am doing this on a remote server so I couldn't use a breakpoint.
I wrapped the entire function in a try block and caught it though..
"Value isn't of type boolean"
which is thrown here obviously:
if(! (value is bool))
{
throw new ArgumentException("Value isn't of type boolean", "value");
}
Ok, that answers the question. Instead of:
bucket.PredicateExpression.AddWithAnd(PredicateFactory.CompareValue(UserFieldIndex.Disabled, ComparisonOperator.NotEqual, 1));
do:
bucket.PredicateExpression.AddWithAnd(PredicateFactory.CompareValue(UserFieldIndex.Disabled, ComparisonOperator.Equal, false));
or: bucket.PredicateExpression.AddWithAnd(UserFields.Disabled==false);
As your field is a boolean, you shouldn't use a numeric value.
Joined: 21-May-2004
Otis wrote:
bucket.PredicateExpression.AddWithAnd(UserFields.Disabled==false);
This worked. I am on to my next bug now . Thanks so much for the help.
Joined: 21-May-2004
Hey again
bucket.PredicateExpression.Add(PredicateFactory.CompareValue(ProcessFieldIndex.ProjectId, ComparisonOperator.Equal, projectId));
Is now throwing an error.
"Value isn't of type boolean"
I changed the code to this
bucket.PredicateExpression.Add(ProcessFields.ProjectId == projectId);
Still hitting the same error.
2006-03-09 12:02:42,375 [3008] ERROR WebMissionFire.Login [] - **APPLICATION ERROR - ERROR [42703] [IBM][DB2/NT] SQL0206N "ADMINISTRATOR.PROCESS.PROJECT_ID" is not valid in the context where it is used. SQLSTATE=42703
**
2006-03-09 12:02:42,375 [3008] ERROR WebMissionFire.Login [] - at IBM.Data.DB2.DB2Connection.b(IntPtr A_0, m A_1, x A_2)
at IBM.Data.DB2.DB2Command.a(CommandBehavior A_0, String A_1)
at IBM.Data.DB2.DB2Command.ExecuteReader(CommandBehavior behavior)
at IBM.Data.DB2.DB2Command.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteMultiRowDataTableRetrievalQuery(IRetrievalQuery queryToExecute, DbDataAdapter dataAdapterToUse, DataTable tableToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedList(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedList(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, Boolean allowDuplicates)
at MissionFire.BLL.ReportEngine.ReportEngineManager.UpcomingEvents(Int32 dias, Int32 userId, Int32 projectId) in c:\missionfiresource\missionfire\reportengine\reportenginemanager.cs:line 1426
at WebMissionFire.Project.PPOverviewTab.Page_Load(Object sender, EventArgs e) in \\192.168.1.200\c$\webmissionfire\project\ppoverviewtab.aspx.cs:line 244
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
Joined: 21-May-2004
Otis wrote:
I don't think projectid is of type boolean, is it?
![]()
So I think you should remove the type converter from the projectid field?
I had a feeling you were going to say that
/// <summary>
/// Generates the PersistenceInfoBucket for the entity 'Process'.
/// </summary>
/// <returns>The requested, populated PersistenceInfoBucket for the entity 'Process'</returns>
private static PersistenceInfoBucket CreateProcessEntityBucket()
{
PersistenceInfoBucket toReturn = new PersistenceInfoBucket();
toReturn.AddFieldPersistenceInfo("ProcessId", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "PROCESS_ID", false, (int)DB2Type.Integer, 0, 0, 10, true, "IDENTITY_VAL_LOCAL()", null, typeof(System.Int3?)));
toReturn.AddFieldPersistenceInfo("ProcessName", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "PROCESS_NAME", false, (int)DB2Type.VarChar, 500, 0, 0, false, "", null, typeof(System.String)));
toReturn.AddFieldPersistenceInfo("ProcessDescription", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "PROCESS_DESCRIPTION", false, (int)DB2Type.VarChar, 500, 0, 0, false, "", null, typeof(System.String)));
toReturn.AddFieldPersistenceInfo("ParentProcessId", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "PARENT_PROCESS_ID", false, (int)DB2Type.Integer, 0, 0, 10, false, "", null, typeof(System.Int32)));
toReturn.AddFieldPersistenceInfo("ProjectId", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "PROJECT_ID", false, (int)DB2Type.Integer, 0, 0, 10, false, "", null, typeof(System.Int32)));
toReturn.AddFieldPersistenceInfo("ProcessStatusId", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "PROCESS_STATUS_ID", false, (int)DB2Type.Integer, 0, 0, 10, false, "", null, typeof(System.Int32)));
toReturn.AddFieldPersistenceInfo("StartDate", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "START_DATE", false, (int)DB2Type.Timestamp, 0, 0, 0, false, "", null, typeof(System.DateTime)));
toReturn.AddFieldPersistenceInfo("TargetDate", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "TARGET_DATE", false, (int)DB2Type.Timestamp, 0, 0, 0, false, "", null, typeof(System.DateTime)));
toReturn.AddFieldPersistenceInfo("Duration", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "DURATION", false, (int)DB2Type.Integer, 0, 0, 10, false, "", null, typeof(System.Int32)));
toReturn.AddFieldPersistenceInfo("UserId", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "USER_ID", false, (int)DB2Type.Integer, 0, 0, 10, false, "", null, typeof(System.Int32)));
toReturn.AddFieldPersistenceInfo("CreatedOn", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "CREATED_ON", false, (int)DB2Type.Timestamp, 0, 0, 0, false, "", null, typeof(System.DateTime)));
toReturn.AddFieldPersistenceInfo("ModifiedOn", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "MODIFIED_ON", false, (int)DB2Type.Timestamp, 0, 0, 0, false, "", null, typeof(System.DateTime)));
toReturn.AddFieldPersistenceInfo("CompletedValue", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "COMPLETED_VALUE", false, (int)DB2Type.Integer, 0, 0, 10, false, "", null, typeof(System.Int32)));
toReturn.AddFieldPersistenceInfo("EndDate", new FieldPersistenceInfo(@"ADMINISTRATOR", "PROCESS", "END_DATE", false, (int)DB2Type.Timestamp, 0, 0, 0, false, "", null, typeof(System.DateTime)));
return toReturn;
}
There isn't a converter assigned to it. I stripped out all but one of the predicates for the function and it is still throwing an error. I hate DB2's error messages
This project started out as SQL Server. I have to get it running on DB2 and finally Oracle. It's making for a fun time ..
Joined: 21-May-2004
I have remote debugging working with this solution now as well
DCOM Configuration screws it up after Service Pack2 is installed.
If you examine the query and the parameters send, the type of the value etc. (by enabling tracing), what exactly is send and what is thus the cause? It can also be you need to specify an alias in the predicate declaration, as you're using a typedlist...
Joined: 21-May-2004
Otis wrote:
If you examine the query and the parameters send, the type of the value etc. (by enabling tracing), what exactly is send and what is thus the cause? It can also be you need to specify an alias in the predicate declaration, as you're using a typedlist...
![]()
I created the alias in the predicate declaration and turned on tracing. This is what I am getting:
Generated Sql query:
Query: SELECT DISTINCT "Process"."PROCESS_NAME" AS "PathwayName", "Process"."PROCESS_DESCRIPTION" AS "Description", "Process"."PROCESS_ID" AS "ProcessId" FROM "ADMINISTRATOR"."PROCESS" AS "Process" WHERE ( ( "projCompare"."PROJECT_ID" = ?))
Parameter: @ProjectId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Joined: 21-May-2004
OK, I fixed it!
The example I used above was a simplied version of the query I actually needed. Here is what the full query SHOULD have looked liked:
SELECT DISTINCT "ADMINISTRATOR"."PROCESS"."PROCESS_NAME" AS "PathwayName", "ADMINISTRATOR"."PROCESS"."PROCESS_DESCRIPTION" AS "Description", "ADMINISTRATOR"."PROCESS"."PROCESS_ID" AS "ProcessId" FROM (( "ADMINISTRATOR"."PROCESS" INNER JOIN "ADMINISTRATOR"."USER_PERMISSION" ON "ADMINISTRATOR"."PROCESS"."PROCESS_ID"="ADMINISTRATOR"."USER_PERMISSION"."PROCESS_ID") INNER JOIN "ADMINISTRATOR"."PROJECT" ON "ADMINISTRATOR"."PROJECT"."PROJECT_ID"="ADMINISTRATOR"."PROCESS"."PROJECT_ID") WHERE ( ( ( "ADMINISTRATOR"."PROCESS"."TARGET_DATE" BETWEEN ? AND ? OR "ADMINISTRATOR"."PROCESS"."START_DATE" BETWEEN ? AND ?) AND "ADMINISTRATOR"."USER_PERMISSION"."USER_ID" = ? AND "ADMINISTRATOR"."USER_PERMISSION"."USER_ID" = ? AND ( "ADMINISTRATOR"."PROCESS"."PROCESS_STATUS_ID" = ? OR "ADMINISTRATOR"."PROCESS"."PROCESS_STATUS_ID" = ?) AND "ADMINISTRATOR"."PROCESS"."PROJECT_ID" = ?))
Here is how the fields are being defined (Correctly)
//define the fields for the datatable
ResultsetFields fields = new ResultsetFields(3);
fields.DefineField(ProcessFieldIndex.ProcessName, 0, "PathwayName");
fields.DefineField(ProcessFieldIndex.ProcessDescription, 1, "Description");
fields.DefineField(ProcessFieldIndex.ProcessId, 2, "ProcessId");
If I use an alias such as "Process" in the field definition I am getting this as a query:
SELECT DISTINCT "Process"."PROCESS_NAME" AS "PathwayName", "Process"."PROCESS_DESCRIPTION"
...
So it looks like the error was in the alias of the field definition. Is this an error? Thanks again for your help.
Joined: 21-May-2004
Otis wrote:
Where do you set the predicate alias "projCompare"? You shouldn't.
(edit) too late
![]()
![]()
What should I do about this?
fields.DefineField(ProcessFieldIndex.ProcessId, 3, "Late Pathways", "Process",AggregateFunction.CountDistinct);
I will end up getting this: ""Process.PROCESS_ID" is not valid in the context where it is used.
There doesn't seem to be a way to omit the alias here.
EDIT***
fields.DefineField(ProcessFieldIndex.ProcessId, 3, "Late Pathways");
fields.DefineField(ArtifactFieldIndex.ArtifactId, 4, "Late Files");
fields[3].AggregateFunctionToApply = AggregateFunction.CountDistinct;
fields[4].AggregateFunctionToApply = AggregateFunction.Count;
Seemed to be a good work around