Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 93034 invoked from network); 30 Jul 2009 21:30:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Jul 2009 21:30:16 -0000 Received: (qmail 67072 invoked by uid 500); 30 Jul 2009 21:30:16 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 67049 invoked by uid 500); 30 Jul 2009 21:30:16 -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 67039 invoked by uid 99); 30 Jul 2009 21:30:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jul 2009 21:30:16 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of tobias.schoessler@gmail.com designates 209.85.220.221 as permitted sender) Received: from [209.85.220.221] (HELO mail-fx0-f221.google.com) (209.85.220.221) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Jul 2009 21:30:06 +0000 Received: by fxm21 with SMTP id 21so946784fxm.27 for ; Thu, 30 Jul 2009 14:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=fTzwIoBzF2ammhTckNzJejNO2mFlXJaOuJvtnQWUnso=; b=wke85/eY2jGJzUpAoBpO2HiJojj3r1DId0wvLHg/9ZPSOjFb4CD7fWmLShHpbq9O2m uMx+ss7f9nxzpNjW4e/9CuoaJMELEG2Pkh2gf7qhgtEQiUaBYOOTdpmfkbZBDy20SY4F 9J/yBqPdQU73MimNGKXym1GKTkRe/IdKtoVEE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=hQwGU50B3A0Izs3Wgw+Mew/9NI1VVdkUZzij5knk8r4iKiEgWBRZLcGEdSovvwDrjn V9xTdhyo2FzTvwEY5WKoB6n8WjASkX4kzAtkYkKmrEfOjTVpbJ+1CK59Ev0Uv020S2OR 9Ja6RfxsehOHfIXoz4tl5Z01BFxtBObNRm2uc= MIME-Version: 1.0 Received: by 10.204.68.15 with SMTP id t15mr1734081bki.139.1248989384288; Thu, 30 Jul 2009 14:29:44 -0700 (PDT) In-Reply-To: <5adb61290907301343n308e7e7btfc63209aa568ef3@mail.gmail.com> References: <47737185-C7D8-4A71-9ED0-A2F59FC7A17F@foolishgames.com> <5adb61290907301343n308e7e7btfc63209aa568ef3@mail.gmail.com> Date: Thu, 30 Jul 2009 23:29:44 +0200 Message-ID: <791e0eb60907301429u53af3845k39fbb8957542d9f2@mail.gmail.com> Subject: Re: Strange Problem From: Tobias Schoessler To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=001636c5bcf9942b1c046ff30066 X-Virus-Checked: Checked by ClamAV on apache.org --001636c5bcf9942b1c046ff30066 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Lucas, my experience with mysql Autoincrement fields is that you have to map them as Long. there is some bug in the mysql jdbc driver which returns wrong meta information types if the field is set to autoincrement and some other type than BigInt. See http://lists.mysql.com/java/6383 On Thu, Jul 30, 2009 at 10:43 PM, Michael Gentry wrote: > You shouldn't need to write your own method to get the office ID. Add > the mapping to your ObjEntity by hand and regenerate the Java class > and it should create a getOfficeId() for you. > > mrg > > > On Thu, Jul 30, 2009 at 4:27 PM, Lucas Holt wrote: > > I've got a situation where I need to obtain the primary key. My solution > > was to add a method like so: > > > > public Byte getOfficeId() { > > return (getObjectId() != null && !getObjectId().isTemporary()) > > ? (Byte) > > getObjectId().getIdSnapshot().get(OFFICE_ID_PK_COLUMN) > > : null; > > } > > > > > > However, sometimes I get back a Byte and other times a Short. I've > verified > > this with getClass().getName() > > > > How exactly does the data type get chosen here? Any suggestions? > > > > I've thought about just testing for the cases where the type is different > > and converting it, but it seems like this shouldn't be happening. > > > > Here's the table definition: > > > > CREATE TABLE IF NOT EXISTS `office` ( `office_id` tinyint(3) unsigned NOT > > NULL AUTO_INCREMENT, `country_id` smallint(5) unsigned NOT NULL, > > `company_id` tinyint(3) unsigned NOT NULL, `name` varchar(45) NOT NULL, > > `address` tinytext NOT NULL, PRIMARY KEY (`office_id`), KEY > > `office_country_id` (`country_id`), KEY `office_company` (`company_id`) ) > > ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; > > > > I'm using Cayenne 2.0.4, MySQL 5.1, mysql-connector-java-5.0.5, and java > > version "1.5.0_19" (os x) > > > > > > > > > isMandatory="true" length="255"/> > > > isMandatory="true"/> > > > isMandatory="true" length="5"/> > > isMandatory="true" > > length="45"/> > > > isPrimaryKey="true" isGenerated="true" isMandatory="true" length="3"/> > > > > > > Luke > > > --001636c5bcf9942b1c046ff30066--