cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marek Šabo <ms...@buk.cvut.cz>
Subject String-with-number sort and insert order preservation
Date Wed, 03 Feb 2010 00:45:16 GMT
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


Mime
View raw message