Return-Path: Delivered-To: apmail-incubator-cayenne-user-archive@locus.apache.org Received: (qmail 85359 invoked from network); 29 Aug 2006 12:16:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Aug 2006 12:16:46 -0000 Received: (qmail 26962 invoked by uid 500); 29 Aug 2006 12:16:46 -0000 Delivered-To: apmail-incubator-cayenne-user-archive@incubator.apache.org Received: (qmail 26710 invoked by uid 500); 29 Aug 2006 12:16:45 -0000 Mailing-List: contact cayenne-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-user@incubator.apache.org Delivered-To: mailing list cayenne-user@incubator.apache.org Received: (qmail 26701 invoked by uid 99); 29 Aug 2006 12:16:45 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Aug 2006 05:16:45 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of Tobias.Schoessler@unvienna.org designates 193.138.94.41 as permitted sender) Received: from [193.138.94.41] (HELO mx4.unvienna.org) (193.138.94.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Aug 2006 05:16:43 -0700 Received: from unvsmtp2.unvienna.org (unvsmtp2.unvienna.org [172.17.252.136]) by mx4.unvienna.org (8.12.11/8.12.11) with ESMTP id k7TCGKNL014473 for ; Tue, 29 Aug 2006 14:16:20 +0200 In-Reply-To: Subject: Re: Problems with MySql id type with AUTO_INCREMENT To: cayenne-user@incubator.apache.org Cc: cayenne-user@incubator.apache.org X-Mailer: Lotus Notes Release 7.0.1 January 17, 2006 Message-ID: From: Tobias SCHOESSLER Date: Tue, 29 Aug 2006 14:16:17 +0200 X-MIMETrack: Serialize by Router on unvsmtp2/VIENNA/UNO(Release 7.0.1|January 17, 2006) at 29/08/2006 14:16:20 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N But still you are right there is a bug in mysql too. If the column type is INT and not INT UNSIGNED it should return java.lang.Integer but it returns java.lang.Long instead. This was my first observation. http://lists.mysql.com/java/6383 this is from jconnector 3.0.8 but I don't see it fixed in the 3.1.13 release notes. So this is the reason why I got a class cast exception for the PK in the first place. Then I changed the mysql datatype to INT UNSIGNED. but why does cayenne need BIGINT mapping set for the column to retrieve it as a java.lang.Long? I understand that this is unrelated to the bug in the mysql jdbc driver mentioned above. Andrus Adamchik To cayenne-user@incubator.apache.org Tuesday, 29 cc August 2006 13:45 Subject Re: Problems with MySql id type Please respond to with AUTO_INCREMENT cayenne-user@incu bator.apache.org You are right: "INTEGER [UNSIGNED] [...] java.lang.Integer, if UNSIGNED java.lang.Long". Who would've thought! :-) I'd appreciate a Jira issue so that we don't forget about it. Andrus On Aug 29, 2006, at 3:40 PM, Tobias SCHOESSLER wrote: > For the driver I use mysql-connector-java-3.1.13-bin.jar > > here > > http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-type- > conversions.html > > it reads that INT UNSIGNED should map to java.lang.Long. This is > fine I > think and it is correct right after creation of the object. > > But why is the type of the column java.lang.Integer when I retrieve > the > value later via cayenne? Isn't the bug rather to search there? > > > > > > > Andrus Adamchik > > le.org> To > cayenne- > user@incubator.apache.org > Tuesday, > 29 cc > August 2006 13:27 > > Subject > Re: Problems with MySql id type > Please respond to with AUTO_INCREMENT > cayenne-user@incu > bator.apache.org > > > > > > > > > I don't think that globally changing INT to be mapped to JDBC BIGINT > is a good idea (although this can be done by editing org/objectstyle/ > cayenne/dba/mysql/types.xml). What is confusing to me is why the > generated key is java.lang.Long for the INTEGER column. Could be a > MySQL driver bug??? > > Andrus > > > On Aug 29, 2006, at 3:15 PM, Tobias SCHOESSLER wrote: > >> it was mapped as >> >> >> >> I changed the type to BIGINT and now the PK is always a Long. Great, >> thanks. This was hard to guess. >> >> Is the jdbc type mapping messed up for the MySQL Adapter? >> >> When I reverse engineer the db from scratch >> >> INT UNSIGNED is mapped as > length="10"/> >> >> INT is mapped as >> >> Could you give me a hint where to change this mapping so I do not >> have to >> set it to BIGINT manually? >> >> thank you >> >> Tobias >> >> >> >> >> >> Andrus Adamchik >> > >> le.org> To >> cayenne- >> user@incubator.apache.org >> Tuesday, >> 29 cc >> August 2006 11:00 >> >> Subject >> Re: Problems with MySql id >> type >> Please respond to with AUTO_INCREMENT >> cayenne-user@incu >> bator.apache.org >> >> >> >> >> >> >> >> >> How is the column mapped in the Modeler? Have you tried mapping it as >> BIGINT? >> >> Andrus >> >> >> >> On Aug 28, 2006, at 1:22 PM, Tobias SCHOESSLER wrote: >> >>> >>> I use cayenne 1.2, MySql. AUTO_INCREMENT ids >>> >>> the type of the id field in the mysql schema is set to >>> >>> INT NOT NULL AUTO_INCREMENT UNIQUE >>> >>> I create an object of this table with cayenne and commit. I see the >>> row >>> inserted ok. When accessing the Id of the object via >>> >>> getObjectId().getIdSnapshot().get(this.FOLDER_UID_PK_COLUMN) >>> >>> in the same DataContext the type of the Object retruned is a Long. >>> (Though >>> I would have expected it to be an Integer from the MySql jdbc >>> documentation) >>> >>> When I use a fresh DataContext and retrieve the same row the id >>> object >>> returned by >>> >>> getObjectId().getIdSnapshot().get(this.FOLDER_UID_PK_COLUMN) >>> >>> seems to be an Integer ? >>> >>> >>> >>> I tried to set the type to >>> >>> INT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE >>> >>> which is supposed to be of Long type from the jdbc type >>> documentation of >>> MySql. >>> >>> to force the id object always to be a Long but cayenne still >>> returns an >>> Integer when reading from the db. >>> >>> any ideas? >>> >>> thanks >>> >>> >>> >>> >> >> >> >> > > > >