You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by yongbl <i_...@yahoo.com.sg> on 2007/06/18 15:03:58 UTC

Common attributes in the model

Hi,
   
  I am new to Cayenne. In many of the models that I am using, there are common attributes like created date, modified date, created by, etc. Is there a right way to add the common attributes, other than manually adding the common attributes in the models?
   
  It seems that I can't create a base model with the common attributes, and extend the rest of the models from the base model, right?
   
  Regards,
  James

       
---------------------------------
 Yahoo! Movies - Search movie info and celeb profiles and photos.

RE: Common attributes in the model

Posted by Fredrik Liden <fl...@translate.com>.
I think you may not be talking about the same thing?

Malcolm, we can configure it so the classes extend a specified
superclass and add basic general functionality. But any attributes that
are listed in that superclass can they really be persisted with Cayenne?

That would require some form of mapping of those common attributes to
DBEntities somewhere? and more complex database generation. How would
all classes inheriting those attributes know to add those attributes to
their individual DBEntity or/and add code to the table creation
statements?

I'd be interested to know if this is possible too. I have date_created,
and created_by, date_modified, and modified_by in many tables.

Thanks,
Fredrik

-----Original Message-----
From: yongbl [mailto:i_yongbl@yahoo.com.sg] 
Sent: Wednesday, June 20, 2007 7:37 AM
To: user@cayenne.apache.org
Subject: Re: Common attributes in the model

Hi Malcolm,
   
  After setting the superclass, I tried to generate the database schema.
But the attributes in the superclass is not reflected in the schema. 
  Do I have to manually add to the database the common attributes? If
so, then settting the superclass didn't offers any time saving since i
still need to add the common attributes :(
   
  Regards,
  James

Malcolm Edgar <ma...@gmail.com> wrote:
  No there is not.

cheers Malcolm

On 6/20/07, yongbl wrote:
>
> Hi Malcolm,
>
> Is there a need to create DBEntity and ObjEntity for the superclass?
>
> Regards,
> James
>

       
---------------------------------
 
 Real people. Real questions. Real answers. Share what you know.

Re: Common attributes in the model

Posted by yongbl <i_...@yahoo.com.sg>.
Hi Malcolm,
   
  After setting the superclass, I tried to generate the database schema. But the attributes in the superclass is not reflected in the schema. 
  Do I have to manually add to the database the common attributes? If so, then settting the superclass didn't offers any time saving since i still need to add the common attributes :(
   
  Regards,
  James

Malcolm Edgar <ma...@gmail.com> wrote:
  No there is not.

cheers Malcolm

On 6/20/07, yongbl wrote:
>
> Hi Malcolm,
>
> Is there a need to create DBEntity and ObjEntity for the superclass?
>
> Regards,
> James
>

       
---------------------------------
 
 Real people. Real questions. Real answers. Share what you know.

Re: Common attributes in the model

Posted by Malcolm Edgar <ma...@gmail.com>.
No there is not.

cheers Malcolm

On 6/20/07, yongbl <i_...@yahoo.com.sg> wrote:
>
> Hi Malcolm,
>
>   Is there a need to create DBEntity and ObjEntity for the superclass?
>
>   Regards,
>   James
>
> Malcolm Edgar <ma...@gmail.com> wrote:
>   Hi James,
>
> Yes you can. In the modeler, you define a common "Custom Superclass" under
> the DataMap "Entity Defaults". Make sure you custom superclass extends
> DataObject, and add your common attributes. You generated classes will
> then
> extend your common superclass.
>
> Make sure your DB Entities support these attributes.
>
> regards Malcolm Edgar
>
> On 6/18/07, yongbl wrote:
> >
> > Hi,
> >
> > I am new to Cayenne. In many of the models that I am using, there are
> > common attributes like created date, modified date, created by, etc. Is
> > there a right way to add the common attributes, other than manually
> adding
> > the common attributes in the models?
> >
> > It seems that I can't create a base model with the common attributes,
> > and extend the rest of the models from the base model, right?
> >
> > Regards,
> > James
> >
> >
> > ---------------------------------
> > Yahoo! Movies - Search movie info and celeb profiles and photos.
>
>
>
> ---------------------------------
>
> Real people. Real questions. Real answers. Share what you know.

Re: Common attributes in the model

Posted by yongbl <i_...@yahoo.com.sg>.
Hi Malcolm,
   
  Is there a need to create DBEntity and ObjEntity for the superclass? 
   
  Regards,
  James

Malcolm Edgar <ma...@gmail.com> wrote:
  Hi James,

Yes you can. In the modeler, you define a common "Custom Superclass" under
the DataMap "Entity Defaults". Make sure you custom superclass extends
DataObject, and add your common attributes. You generated classes will then
extend your common superclass.

Make sure your DB Entities support these attributes.

regards Malcolm Edgar

On 6/18/07, yongbl wrote:
>
> Hi,
>
> I am new to Cayenne. In many of the models that I am using, there are
> common attributes like created date, modified date, created by, etc. Is
> there a right way to add the common attributes, other than manually adding
> the common attributes in the models?
>
> It seems that I can't create a base model with the common attributes,
> and extend the rest of the models from the base model, right?
>
> Regards,
> James
>
>
> ---------------------------------
> Yahoo! Movies - Search movie info and celeb profiles and photos.


 		
---------------------------------
 
 Real people. Real questions. Real answers. Share what you know.

Re: Common attributes in the model

Posted by Malcolm Edgar <ma...@gmail.com>.
Hi James,

Yes you can. In the modeler, you define a common "Custom Superclass" under
the DataMap "Entity Defaults". Make sure you custom superclass extends
DataObject, and add your common attributes. You generated classes will then
extend your common superclass.

Make sure your DB Entities support these attributes.

regards Malcolm Edgar

On 6/18/07, yongbl <i_...@yahoo.com.sg> wrote:
>
> Hi,
>
>   I am new to Cayenne. In many of the models that I am using, there are
> common attributes like created date, modified date, created by, etc. Is
> there a right way to add the common attributes, other than manually adding
> the common attributes in the models?
>
>   It seems that I can't create a base model with the common attributes,
> and extend the rest of the models from the base model, right?
>
>   Regards,
>   James
>
>
> ---------------------------------
> Yahoo! Movies - Search movie info and celeb profiles and photos.