On 2012-03-14, at 7:17 AM, Stéphan Mertz wrote:
> Ok, I found my problem.
> In the version before prototype of my models, I have this kind of derived
> attributes :
> For MySQL :
> {
> allowsNull = Y;
> definition = "((TO_DAYS(NOW()) - TO_DAYS(patient.dateNaiss)) -
> (TO_DAYS(NOW()) - TO_DAYS(dateArrivee)))/365";
> externalType = MEDIUMINT;
> isReadOnly = Y;
> name = agePatientAnnee;
> valueClassName = NSNumber;
> valueType = i;
> },
>
> For Oracle :
> {
> allowsNull = Y;
> definition = "trunc((to_number(to_char((dateArrivee),'J')) -
> to_number(to_char((patient.dateNaiss),'J')))/365)";
> externalType = NUMBER;
> isReadOnly = Y;
> name = agePatientAnnee;
> valueClassName = NSNumber;
> valueType = i;
> },
>
> I don't know if it is a really supported use of derived attributes, but it
> works fine.
I don't know either. You would not be able to update or lock on this, so maybe
it was not intended. I have rarely, maybe never, used derived prototypes.
> The problem is that prototype doesn't synchronize the definition setting of
> an attribute.
I think that could be considered a bug, assuming this is a valid use of derived
attributes. Try using the Read Format instead. That will work with prototypes.
Chuck
> So, the prototype version below doesn't work :
>
> Attribute :
> {
> columnName = "";
> name = agePatientAnnee;
> prototypeName = agePatientAnnee;
> },
>
> MySQL Prototype :
> {
> allowsNull = Y;
> columnName = "";
> definition = "((TO_DAYS(NOW()) - TO_DAYS(patient.dateNaiss)) -
> (TO_DAYS(NOW()) - TO_DAYS(dateArrivee)))/365";
> externalType = MEDIUMINT;
> isReadOnly = Y;
> name = agePatientAnnee;
> valueClassName = NSNumber;
> valueType = i;
> },
>
> Oracle Prototype :
> {
> allowsNull = Y;
> columnName = "";
> definition = "trunc((to_number(to_char((dateArrivee),'J')) -
> to_number(to_char((patient.dateNaiss),'J')))/365)";
> externalType = NUMBER;
> isReadOnly = Y;
> name = agePatientAnnee;
> valueClassName = NSNumber;
> valueType = i;
> },
>
> So, in my Models initialization, I made this workaround :
> NSArray<EOEntity> entities = l_model.entities();
>
> for (EOEntity entity : entities) {
> NSArray<EOAttribute> attrs = entity.attributes();
>
> for (EOAttribute attr : attrs) {
> if (attr.isDerived() && attr.prototype().definition()
> != null)
> attr.setDefinition(attr.prototype().definition());
> }
> }
>
> It works now.
>
> Le 14 mars 2012 à 00:55, Chuck Hill a écrit :
>
>> Maybe you want the Read Format and Write Format on the Advanced tab of the
>> attribute?
>>
>>
>> Chuck
>>
>>
>> On 2012-03-13, at 11:33 AM, Mertz Stéphan wrote:
>>
>>> Hi everybody,
>>>
>>> I have a problem with derived attribute and Prototype : the SQL produced by
>>> EOF tries to fetch a column with the name of the attribute, but not the
>>> derived definition.
>>> What's wrong ?
>>>
>>> Thank you for your help.
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
>>>
>>> This email sent to [email protected]
>>
>> --
>> Chuck Hill Senior Consultant / VP Development
>>
>> Practical WebObjects - for developers who want to increase their overall
>> knowledge of WebObjects or who are trying to solve specific problems.
>> http://www.global-village.net/gvc/practical_webobjects
>>
>>
>>
>>
>>
>>
>>
>>
>
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall
knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/gvc/practical_webobjects
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
