Re: Max Length

From: Michael Gentry (mgentr..asslight.net)
Date: Mon Aug 23 2010 - 12:46:13 UTC

  • Next message: Andrus Adamchik: "Re: Max Length"

    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 <andru..bjectstyle.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.
    >>     *
    >>     *..aram attribute The attribute to lookup.
    >>     *..eturn 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
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Mon Aug 23 2010 - 12:47:09 UTC