String-with-number sort and insert order preservation

From: Marek Šab (msab..uk.cvut.cz)
Date: Tue Feb 02 2010 - 19:45:16 EST

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

    Hi all,

    I would like to ask you two questions:

    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?

    2) I was filling ip table with available ranges like this:

    ObjectContext oc = DataContext.getThreadObjectContext();

            for (int i = 33; i < 255; i++) {

                Ip4Address ip = oc.newObject(Ip4Address.class);

                ip.setIpAddress("XX.XX.XX." + i);

                ip.setUsed(Boolean.FALSE);

                ip.setNat(Boolean.FALSE);

            }

    but cayenne inserted rows like this (probably hashed order for
    optimization):

    INFO - QueryLogger - [bind: 1->ipAddress:'XX.XX.XX.97', 2->nat:'false', 3->used:'false']

    INFO - QueryLogger - Generated PK: Ip4Address.id = 1

    INFO - QueryLogger - === updated 1 row.

    INFO - QueryLogger - [bind: 1->ipAddress:'XX.XX.XX.71', 2->nat:'false', 3->used:'false']

    INFO - QueryLogger - Generated PK: Ip4Address.id = 2

    INFO - QueryLogger - === updated 1 row.

    Is there any way how to override this mechanism in order to preserve
    order of inserted rows?

    TIA,

    --
    Marek Šabo
    



    This archive was generated by hypermail 2.0.0 : Tue Feb 02 2010 - 19:45:55 EST