Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 66855 invoked from network); 3 Feb 2010 01:07:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Feb 2010 01:07:24 -0000 Received: (qmail 56668 invoked by uid 500); 3 Feb 2010 01:07:24 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 56648 invoked by uid 500); 3 Feb 2010 01:07:24 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 56638 invoked by uid 99); 3 Feb 2010 01:07:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 01:07:24 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [59.167.240.32] (HELO fish.ish.com.au) (59.167.240.32) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Feb 2010 01:07:14 +0000 Received: from ip-149.ish.com.au ([203.29.62.149]:52772) by fish.ish.com.au with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1NcU2G-0002fW-2p for user@cayenne.apache.org; Wed, 03 Feb 2010 12:28:04 +1100 Message-ID: <4B68CC29.9050609@maniatis.org> Date: Wed, 03 Feb 2010 12:06:49 +1100 From: Aristedes Maniatis User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1 MIME-Version: 1.0 To: user@cayenne.apache.org Subject: Re: String-with-number sort and insert order preservation References: <4B68C71C.8030007@buk.cvut.cz> In-Reply-To: <4B68C71C.8030007@buk.cvut.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org On 3/02/10 11:45 AM, Marek Ĺ abo 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? I doubt any database is going to be able to cope with that sorting, so you are going to have to do that in memory after you have fetched all your data. > Is there any way how to override this mechanism in order to preserve > order of inserted rows? Meaningful primary keys are usually considered evil when using an ORM (and even if you aren't). You are far better off adding another sortOrder field (could be int or perhaps a datetime) which is under your control and let the primary key be used only as a primary key. Ari -- --------------------------> Aristedes Maniatis GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A