Re: weird sql generation problem
Re: weird sql generation problem
- Subject: Re: weird sql generation problem
- From: Tim Worman <email@hidden>
- Date: Mon, 31 Aug 2009 17:17:33 -0700
On Aug 31, 2009, at 3:27 PM, Ray Kiddy wrote:
On Aug 31, 2009, at 2:54 PM, Tim Worman wrote:
WO'ers:
My app is crashing with an sql error that looks like this:
SQL ERROR - [position 572, near 'WHERE' in 'IBUTION t0 WHERE
(t0.is_d'] (1) field 'id' not found in table 'FUND_DISTRIBUTION'.
SQL: SELECT t0.account_number, t0.appt_begin_date, t0.appt_num,
t0.cost_center_code, t0.create_date, t0.dist_dept_code,
t0.dist_num, t0.dist_off_above, t0.dist_payrate_hour,
t0.dist_payrate_month, t0.dist_percent, t0.dist_perq, t0.dist_step,
t0.dos_earnings_type, t0.emp_full_name, t0.emp_status,
t0.employee_id, t0.fund_distribution_id, t0.fund_number,
t0.hrly_as_mthly_est, t0.id, t0.is_debit, t0.job_id,
t0.location_code, t0.modify_date, t0.pay_begin_date,
t0.pay_end_date, t0.project, t0.sub_code, t0.sub_location,
t0.title_code, t0.work_study_pgm FROM FUND_DISTRIBUTION t0 WHERE
(t0.is_debit = 'false' AND (t0.dos_earnings_type <> 'STP' AND
t0.dos_earnings_type <> 'RES' AND t0.job_id = 219)) ORDER BY
t0.pay_end_date DESC
In my model there is no "id" attribute for the FundDistribution
entity. The table obviously doesn't have a matching column hence
the error. But why is sql being generated for an attribute that
doesn't exist? I looked at FundDistribution.plist in the model and
there is no "id" attribute in there.
Your model must contain an attribute with some name (which could be
very different than "id") and which has a columnName of "id". You
will not see this by looking at the attribute names.
I've recently been refactoring a large monolithic model/framework
into smaller focused models/frameworks. As part of this I've also
been moving to utilizing prototypes. In some cases I'm using the
"id" prototype for certain primary/foreign key attributes. Could
this be a genesis of this issue?
It certainly could be. You could write your EOModels to stdout and
see what they look like. Prototypes are put in by the tools and so
if you look at the model as it exists in memory, you should be able
to see what it has and what it really does not have. You can either
dump the model out to a temporary file with the writeToFile()
method, the contents of which you can then read in as a
NSDictionary, or iterate through the entities and write out the
lists of attributes. If you look at the columnName() of the
attributes, you should be able to see the bad value.
I grabbed the FundDistribution EOEntity and called toString() and
below is the output. There's no attribute referring to column name "id."
FundDistributionOut: <EOEntity FundDistribution
<EOAttribute accountNumber
columnName : 'account_number'
externalType : 'char'
width : '6'
allowsNull : 'Y'
name : 'accountNumber'
prototypeName : 'shortString'
>
<EOAttribute apptBeginDate
allowsNull : 'Y'
columnName : 'appt_begin_date'
name : 'apptBeginDate'
prototypeName : 'date'
externalType : 'date'
>
<EOAttribute apptNum
name : 'apptNum'
columnName : 'appt_num'
externalType : 'integer'
allowsNull : 'Y'
valueType : 's'
prototypeName : 'intNumber'
>
<EOAttribute costCenterCode
columnName : 'cost_center_code'
externalType : 'char'
width : '2'
allowsNull : 'Y'
name : 'costCenterCode'
prototypeName : 'type'
>
<EOAttribute createDate
allowsNull : 'Y'
columnName : 'create_date'
name : 'createDate'
prototypeName : 'dateTime'
externalType : 'datetime'
>
<EOAttribute distDeptCode
name : 'distDeptCode'
columnName : 'dist_dept_code'
externalType : 'char'
allowsNull : 'Y'
valueType : 'c'
prototypeName : 'type'
>
<EOAttribute distNum
name : 'distNum'
columnName : 'dist_num'
externalType : 'int'
allowsNull : 'Y'
valueType : 's'
prototypeName : 'intNumber'
>
<EOAttribute distOffAbove
allowsNull : 'Y'
columnName : 'dist_off_above'
name : 'distOffAbove'
prototypeName : 'charFlag'
externalType : 'char'
>
<EOAttribute distPayrateHour
allowsNull : 'Y'
columnName : 'dist_payrate_hour'
name : 'distPayrateHour'
prototypeName : 'currencyAmount'
precision : '9'
>
<EOAttribute distPayrateMonth
allowsNull : 'Y'
columnName : 'dist_payrate_month'
name : 'distPayrateMonth'
prototypeName : 'currencyAmount'
precision : '9'
>
<EOAttribute distPercent
name : 'distPercent'
columnName : 'dist_percent'
className : 'java.math.BigDecimal'
externalType : 'float'
allowsNull : 'Y'
scale : '4'
valueType : 'B'
prototypeName : 'doubleNumber'
precision : '5'
>
<EOAttribute distPerq
columnName : 'dist_perq'
externalType : 'char'
width : '3'
allowsNull : 'Y'
name : 'distPerq'
prototypeName : 'type'
>
<EOAttribute distStep
allowsNull : 'Y'
columnName : 'dist_step'
name : 'distStep'
prototypeName : 'type'
externalType : 'char'
>
<EOAttribute dosEarningsType
columnName : 'dos_earnings_type'
externalType : 'char'
width : '3'
allowsNull : 'Y'
name : 'dosEarningsType'
prototypeName : 'type'
>
<EOAttribute empFullName
columnName : 'emp_full_name'
externalType : 'char'
width : '26'
allowsNull : 'Y'
name : 'empFullName'
prototypeName : 'varchar50'
>
<EOAttribute empStatus
allowsNull : 'Y'
columnName : 'emp_status'
name : 'empStatus'
prototypeName : 'charFlag'
externalType : 'char'
>
<EOAttribute employeeId
name : 'employeeId'
columnName : 'employee_id'
externalType : 'char'
width : '9'
allowsNull : 'Y'
valueType : 'c'
prototypeName : 'varchar10'
>
<EOAttribute fundDistributionId
valueType : 'l'
columnName : 'fund_distribution_id'
name : 'fundDistributionId'
prototypeName : 'id'
externalType : 'integer'
>
<EOAttribute fundNumber
columnName : 'fund_number'
externalType : 'char'
width : '5'
allowsNull : 'Y'
name : 'fundNumber'
prototypeName : 'shortString'
>
<EOAttribute hrlyAsMthlyEst
allowsNull : 'Y'
columnName : 'hrly_as_mthly_est'
name : 'hrlyAsMthlyEst'
prototypeName : 'currencyAmount'
precision : '9'
>
<EOAttribute isDebit
name : 'isDebit'
columnName : 'is_debit'
externalType : 'char'
valueFactoryMethodName : 'valueOf'
allowsNull : 'Y'
valueType : 'c'
prototypeName : 'boolean'
>
<EOAttribute jobId
name : 'jobId'
columnName : 'job_id'
externalType : 'integer'
allowsNull : 'Y'
valueType : 'l'
prototypeName : 'id'
>
<EOAttribute locationCode
allowsNull : 'Y'
columnName : 'location_code'
name : 'locationCode'
prototypeName : 'charFlag'
externalType : 'char'
>
<EOAttribute modifyDate
allowsNull : 'Y'
columnName : 'modify_date'
name : 'modifyDate'
prototypeName : 'dateTime'
externalType : 'datetime'
>
<EOAttribute payBeginDate
allowsNull : 'Y'
columnName : 'pay_begin_date'
name : 'payBeginDate'
prototypeName : 'date'
externalType : 'date'
>
<EOAttribute payEndDate
allowsNull : 'Y'
columnName : 'pay_end_date'
name : 'payEndDate'
prototypeName : 'date'
externalType : 'date'
>
<EOAttribute project
columnName : 'project'
externalType : 'char'
width : '6'
allowsNull : 'Y'
name : 'project'
prototypeName : 'shortString'
>
<EOAttribute subCode
columnName : 'sub_code'
externalType : 'char'
width : '2'
allowsNull : 'Y'
name : 'subCode'
prototypeName : 'type'
>
<EOAttribute subLocation
columnName : 'sub_location'
externalType : 'char'
width : '2'
allowsNull : 'Y'
name : 'subLocation'
prototypeName : 'type'
>
<EOAttribute titleCode
allowsNull : 'Y'
columnName : 'title_code'
name : 'titleCode'
prototypeName : 'type'
externalType : 'char'
>
<EOAttribute workStudyPgm
allowsNull : 'Y'
columnName : 'work_study_pgm'
name : 'workStudyPgm'
prototypeName : 'charFlag'
externalType : 'char'
>
<EORelationship job
name : 'job'
isToMany : 'N'
joinSemantic : 'EOInnerJoin'
userInfo : '{}'
internalInfo : '{}'
joins : '({sourceAttribute = "jobId"; destinationAttribute =
"jobId"; })'
destination : 'Job'
>
no indexes
no stored procedures
>
The destination database is OpenBase.
This should not matter. Unless there is an EOSQLExpression bug
specific to OB, the problem is in the model.
- ray
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden