[hibernate-dev] uppercase support in like Expressions

andrea tomassi andrea.tomassi at gmail.com
Tue Jan 29 12:44:06 EST 2008


Hi,
first of all please excuse me for my poor english.
i am a java developer, and i'm using hibernate to implement persistence.
Using Expression.ilike method i had some compatibility problem becouse of
the fixed behaviour of converting fields to lowercase.
So i modified org.hibernate.Criteria.LikeExpression and also
org.hibernate.Criteria.LikeExpressionIlikeExpression classes, to implement
the possibility of choosing the preferred converting mode:
either uppercase or lowercase.
So what i obtained is something like this:


CLASS: org.hibernate.Criteria.IlikeExpression
....

@Deprecated
    protected IlikeExpression(String propertyName, String value, MatchMode
matchMode) {
        this( propertyName, matchMode.toMatchString(value),
CONVERT_MODE_LOWER_CASE);
    }

    protected IlikeExpression(String propertyName, String value, MatchMode
matchMode, int CONVERT_MODE) {
        this( propertyName, matchMode.toMatchString(value), CONVERT_MODE);
    }
....



CLASS: org.hibernate.Criteria.LikeExpression


protected LikeExpression(String propertyName, String value,
            MatchMode matchMode, Character escapeChar, boolean ignoreCase,
            int CONVERT_MODE) {
        this(propertyName, matchMode.toMatchString(value), escapeChar,
                ignoreCase, CONVERT_MODE);
    }
    @Deprecated
    protected LikeExpression(String propertyName, String value,
            MatchMode matchMode, Character escapeChar, boolean ignoreCase) {
        this(propertyName, matchMode.toMatchString(value), escapeChar,
                ignoreCase, LikeExpression.CONVERT_MODE_LOWER_CASE);
    }


both solutions are compatible with the old behaviour, but now i can choose
between uppercase or lowercse convertion.
If you think this could be a correct approach to this problem, please answer
me and i will give you the whole source code reguarding the modify.
Thanks for your attention.
Best Regards

-- 
Andrea Tomassi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20080129/b5d2232a/attachment.html 


More information about the hibernate-dev mailing list