This is how I have always done it:

        // Remove as class property
NSMutableArray classProperties = new NSMutableArray (columnEntity.classProperties());
        classProperties.removeObject(dataAccessNotifications);
        columnEntity.setClassProperties(classProperties);

Chuck


On Apr 25, 2007, at 9:23 PM, Lachlan Deck wrote:

Hi there,

I'm getting tired of manually adding to each entity a 'derivedCount' attribute defined as:
       {
           columnName = "";
           definition = "count(*)";
           externalType = BIGINT;
           name = derivedCount;
           valueClassName = NSNumber;
           valueType = l;
       },

So I'm attempting to add it when the application launches (unsuccessfully so far) whilst the entity is loading.

I think the piece of the puzzle I'm missing is how to set this attribute as a non-class property. Any ideas?

EOEntity anEntity; // assume exists
if ( anEntity.attributeNamed( "derivedCount" ) == null ) {
        EOAttribute derivedCount;
        
        derivedCount = new EOAttribute();
        derivedCount.setValueType( "l" );
        derivedCount.setExternalType( "BIGINT" );
        derivedCount.setName( "derivedCount" );
        derivedCount.setClassName( "java.lang.Long" );
        derivedCount.setColumnName( "__temp__" );
        anEntity.addAttribute( derivedCount );
        derivedCount.setDefinition( "count(*)" );
        derivedCount.setReadOnly( true );
}

No exceptions get thrown here, however when I attempt to do a fetch it complains about the non-existing attribute in the schema.

Thanks.

with regards,
--

Lachlan Deck



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/chill% 40global-village.net

This email sent to [EMAIL PROTECTED]


--

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/products/practical_webobjects





_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to