FAQ
Hi,

I would like to know if there is a way to sort string(varchar) columns
numerically. I know it's bad design but legacy database can't be changed
atm. I'm talking about IPv4 columns, which we need to sort. ( In new
model I aim to store them as integers and map extra column in cayenne
with mysql INET_ATON(), hope it will work.)
I tried to add "+0" to sort order property, but it failed parsing.

Regards,

--
Marek Šabo

Search Discussions

  • Michael Gentry at Sep 23, 2010 at 9:18 pm
    Hi Marek, are you asking if the database can do it or are you wanting
    to do it in your application's memory with (or without) Cayenne?

    mrg
    On Thu, Sep 23, 2010 at 6:35 AM, Marek Šabo wrote:
    Hi,

    I would like to know if there is a way to sort string(varchar) columns
    numerically. I know it's bad design but legacy database can't be changed
    atm. I'm talking about IPv4 columns, which we need to sort. ( In new model I
    aim to store them as integers and map extra column in cayenne with mysql
    INET_ATON(), hope it will work.)
    I tried to add "+0" to sort order property, but it failed parsing.

    Regards,

    --
    Marek Šabo

  • Marek Šabo at Sep 23, 2010 at 9:43 pm
    Hi Michael,

    sorry, my first post was probably confusing.
    I could do it programmatically but I want to know if it is possible with
    cayenne sorting engine, paraphrased, Can I modify sort order property
    for cayenne somehow, e.g. as MySQL function INET_ATON()?

    Meanwhile I can create a template query:

    SELECT ipAddress FROM Ip4Address ORDER BY
    INET_ATON(Ip4Address.ipAddress) ASC

    Regards,

    --
    Marek Šabo


    On 09/23/2010 11:17 PM, Michael Gentry wrote:
    Hi Marek, are you asking if the database can do it or are you wanting
    to do it in your application's memory with (or without) Cayenne?

    mrg
    On Thu, Sep 23, 2010 at 6:35 AM, Marek Šabo wrote:

    Hi,

    I would like to know if there is a way to sort string(varchar) columns
    numerically. I know it's bad design but legacy database can't be changed
    atm. I'm talking about IPv4 columns, which we need to sort. ( In new model I
    aim to store them as integers and map extra column in cayenne with mysql
    INET_ATON(), hope it will work.)
    I tried to add "+0" to sort order property, but it failed parsing.

    Regards,

    --
    Marek Šabo


  • Aristedes Maniatis at Sep 24, 2010 at 12:54 am

    On 24/09/10 7:43 AM, Marek Šabo wrote:
    sorry, my first post was probably confusing.
    I could do it programmatically but I want to know if it is possible with
    cayenne sorting engine, paraphrased, Can I modify sort order property
    for cayenne somehow, e.g. as MySQL function INET_ATON()?

    Meanwhile I can create a template query:

    SELECT ipAddress FROM Ip4Address ORDER BY
    INET_ATON(Ip4Address.ipAddress) ASC
    There is no such thing as the "cayenne sorting engine". Cayenne does its sorting by creating SQL commands to send to the database. Your approach, sorting in by formula inside the database, is probably the best. It is potentially very slow since I don't think you can create an index on a formula inside mysql.

    Ari

    --
    -------------------------->
    Aristedes Maniatis
    GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedSep 23, '10 at 10:33a
activeSep 24, '10 at 12:54a
posts4
users3
websitecayenne.apache.org

People

Translate

site design / logo © 2022 Grokbase