You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Michael Gentry <mg...@masslight.net> on 2010/08/20 14:20:39 UTC

Max Length

One thing I recently added to our common/shared base class is:

    /**
     * Lookup the maximum database length defined in the Cayenne model for
     * the given attribute.
     *
     * @param attribute The attribute to lookup.
     * @return The maximum length for the attribute.
     */
    public int getMaxLength(String attribute)
    {
        return getObjEntity().getAttributeMap().get(attribute).getDbAttribute().getMaxLength();
    }


Would it make sense to add this to CayenneDataObject in 3.1?  We use
it to limit file upload sizes and do client-side validation in the UI.
 I could also see isMandatory() being useful, too.  Scale/precision
not as much, but might help some.

Thoughts?

Thanks,

mrg

Re: Max Length

Posted by Mike Kienenberger <mk...@gmail.com>.
Maybe instead of putting them into something called Cayenne, it would make
more sense to stick them into something along the lines of CayenneModel.

On Mon, Aug 23, 2010 at 9:10 AM, Andrus Adamchik <an...@objectstyle.org>wrote:

> This was my concern all along. Calling a class "Cayenne" imposes certain
> expectations. This should be a collection of frequently-used utility
> methods.
>
> Andrus
>
> On Aug 23, 2010, at 3:57 PM, Andrus Adamchik wrote:
> > On Aug 23, 2010, at 3:46 PM, Michael Gentry wrote:
> >
> >> I wonder if that
> >> class will just start to become a dumping ground in the future?
> >
> > That's what we certainly should try to avoid.
> >
> > Andrus
> >
>
>

Re: Max Length

Posted by Andrus Adamchik <an...@objectstyle.org>.
This was my concern all along. Calling a class "Cayenne" imposes certain expectations. This should be a collection of frequently-used utility methods. 

Andrus

On Aug 23, 2010, at 3:57 PM, Andrus Adamchik wrote:
> On Aug 23, 2010, at 3:46 PM, Michael Gentry wrote:
> 
>> I wonder if that
>> class will just start to become a dumping ground in the future?
> 
> That's what we certainly should try to avoid.
> 
> Andrus
> 


Re: Max Length

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Aug 23, 2010, at 3:46 PM, Michael Gentry wrote:

> I wonder if that
> class will just start to become a dumping ground in the future?

That's what we certainly should try to avoid.

Andrus

Re: Max Length

Posted by Michael Gentry <mg...@masslight.net>.
I remembered a thread a while back regarding trying to keep the API
clean, which is why I didn't just add it.  :-)  I suppose I could add
something to the Cayenne class as you suggested, but I wonder if that
class will just start to become a dumping ground in the future?

Thanks,

mrg


On Mon, Aug 23, 2010 at 8:24 AM, Andrus Adamchik <an...@objectstyle.org> wrote:
> Actually in 3.1 we are moving away from metadata utility methods inside Perissitent/CayenneDataObject. We've already deprecated 'getObjEntity'. A current place for this type of utilities is in org.apache.cayenne.Cayenne (aka DataObjectUtils). There was a discussion about it some time ago. Don't remember the subject off hand.
>
> Also since we should try to keep the API clean, how about condensing that to:
>
>   Cayenne.getDbAttribute(Persistent object, String propertyName) ?
>
> (similar to the existing Cayenne.getProperty(Persistent object, String properyName)).
>
> Andrus
>
>
>
> On Aug 20, 2010, at 3:20 PM, Michael Gentry wrote:
>> One thing I recently added to our common/shared base class is:
>>
>>    /**
>>     * Lookup the maximum database length defined in the Cayenne model for
>>     * the given attribute.
>>     *
>>     * @param attribute The attribute to lookup.
>>     * @return The maximum length for the attribute.
>>     */
>>    public int getMaxLength(String attribute)
>>    {
>>        return getObjEntity().getAttributeMap().get(attribute).getDbAttribute().getMaxLength();
>>    }
>>
>>
>> Would it make sense to add this to CayenneDataObject in 3.1?  We use
>> it to limit file upload sizes and do client-side validation in the UI.
>> I could also see isMandatory() being useful, too.  Scale/precision
>> not as much, but might help some.
>>
>> Thoughts?
>>
>> Thanks,
>>
>> mrg
>>
>
>

Re: Max Length

Posted by Andrus Adamchik <an...@objectstyle.org>.
Actually in 3.1 we are moving away from metadata utility methods inside Perissitent/CayenneDataObject. We've already deprecated 'getObjEntity'. A current place for this type of utilities is in org.apache.cayenne.Cayenne (aka DataObjectUtils). There was a discussion about it some time ago. Don't remember the subject off hand.

Also since we should try to keep the API clean, how about condensing that to:

   Cayenne.getDbAttribute(Persistent object, String propertyName) ?

(similar to the existing Cayenne.getProperty(Persistent object, String properyName)).

Andrus



On Aug 20, 2010, at 3:20 PM, Michael Gentry wrote:
> One thing I recently added to our common/shared base class is:
> 
>    /**
>     * Lookup the maximum database length defined in the Cayenne model for
>     * the given attribute.
>     *
>     * @param attribute The attribute to lookup.
>     * @return The maximum length for the attribute.
>     */
>    public int getMaxLength(String attribute)
>    {
>        return getObjEntity().getAttributeMap().get(attribute).getDbAttribute().getMaxLength();
>    }
> 
> 
> Would it make sense to add this to CayenneDataObject in 3.1?  We use
> it to limit file upload sizes and do client-side validation in the UI.
> I could also see isMandatory() being useful, too.  Scale/precision
> not as much, but might help some.
> 
> Thoughts?
> 
> Thanks,
> 
> mrg
>