Some databases support VIEWs. You can make your database view parse
and sort your varchar field into four fields.
But you have to treat inserting/updating a record differently than
viewing it if you go this route.
On Tue, Feb 2, 2010 at 7:45 PM, Marek Šabo <msab..uk.cvut.cz> wrote:
> 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 : Wed Feb 03 2010 - 08:44:55 EST