Re: String-with-number sort and insert order preservation

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Wed Feb 03 2010 - 07:44:31 EST

  • Next message: Aristedes Maniatis: "Re: String-with-number sort and insert order preservation"

    Actually, no. If you need to index data by IP, you just add indexing by IP
    column. If you want to perform in future meaningful sort by meaningless IP,
    you will have to think about such cases as changes the IP column - then the
    order might break. Answering your question, if you really think you need
    control over PK values, you either use custom PKs (and generate them
    yourself), or, if the speed isn't priority, do many sequent commits instead
    of one (if the logic of your app allows you)

    2010/2/3 Marek Šabo <msab..uk.cvut.cz>

    > Thank you all for your ideas, my progress:
    >
    >
    >
    > 1) Is there any way to sort varchar fields which happen to numbers, more
    >> precisely ipv4s?
    >> query.addOrdering(Ip4Address.IP_ADDRESS_PROPERTY, SortOrder.ASCENDING);
    >> This of course sets the hundreds as first in line, any tips on some
    >> custom sorting?
    >>
    >>
    > I just implemented custom comparator and added the result list from query
    > to treeset - anyway the IPs are unique.
    >
    >> 2) Is there any way how to override this mechanism in order to preserve
    >> order of inserted rows?
    >>
    >>
    >>
    > This one I can't really cope with. Of course I could fill it in ten other
    > ways which will preserve the order of inserted rows, so really, haven't any
    > of you ever needed or wanted the data to be indexed by auto-generated pk in
    > order you add them to context while in persisting phase? Because that would
    > nicely solve issue #1 as well because the IPs would be sorted according to
    > pk. This is collateral functionality that's why it isn't designed as OOP
    > would preach.
    >
    > Regards,
    >
    > Marek
    >

    -- 
    Andrey
    



    This archive was generated by hypermail 2.0.0 : Wed Feb 03 2010 - 07:45:25 EST