• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Derived attribute and Prototype
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Derived attribute and Prototype


  • Subject: Re: Derived attribute and Prototype
  • From: Stéphan Mertz <email@hidden>
  • Date: Wed, 14 Mar 2012 15:17:06 +0100

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.
The problem is that prototype doesn't synchronize the definition setting of an attribute.
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@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> --
> 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
>
>
>
>
>
>
>
>


 _______________________________________________
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


References: 
 >Derived attribute and Prototype (From: Mertz Stéphan <email@hidden>)

  • Prev by Date: Re: [ANN] WOInject 1.0
  • Next by Date: Re: Many-To-Many Relationship across DB with different users
  • Previous by thread: Derived attribute and Prototype
  • Next by thread: [ANN] WOInject 1.0
  • Index(es):
    • Date
    • Thread