• 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: Dynamically adding a derived attribute
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamically adding a derived attribute


  • Subject: Re: Dynamically adding a derived attribute
  • From: Kieran Kelleher <email@hidden>
  • Date: Thu, 26 Apr 2007 06:06:53 -0400

it might be worthwhile to look at the Wonder source code in EOAccess/ EOControl *Utilities.java for hints. IIRC they do this on the fly for the count* convenience methods.

On Apr 26, 2007, at 12:23 AM, 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@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


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
References: 
 >Dynamically adding a derived attribute (From: Lachlan Deck <email@hidden>)

  • Prev by Date: Re: Multiple clients in single DB
  • Next by Date: problem with delete rule (relationship)
  • Previous by thread: Re: Dynamically adding a derived attribute
  • Next by thread: problem with delete rule (relationship)
  • Index(es):
    • Date
    • Thread