Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 86854 invoked from network); 13 Jan 2009 16:45:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jan 2009 16:45:07 -0000 Received: (qmail 77502 invoked by uid 500); 13 Jan 2009 16:45:06 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 77246 invoked by uid 500); 13 Jan 2009 16:45:06 -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 77235 invoked by uid 99); 13 Jan 2009 16:45:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jan 2009 08:45:06 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 13 Jan 2009 16:44:59 +0000 Received: (qmail 19015 invoked from network); 13 Jan 2009 16:44:38 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by localhost with SMTP; 13 Jan 2009 16:44:38 -0000 Message-Id: <7D0FB55C-F231-4E19-A078-CFB08E900589@objectstyle.org> From: Andrus Adamchik To: user@cayenne.apache.org In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Re: Modeler Exception for using dots on attributes Date: Tue, 13 Jan 2009 18:44:37 +0200 References: X-Mailer: Apple Mail (2.929.2) X-Virus-Checked: Checked by ClamAV on apache.org Hi Javier, This is definitely a limitation, and as you've discovered, there are 2 =20= issues here. 1. Dot is a standard path separator in Cayenne (you are the first one =20= in so many years of Cayenne who has dots in column names; I am not =20 saying this is illegal, rather that nobody in the community has done =20 it before). So looks like we'll need to have some internal escaping of =20= dots invisible to the user. May not be too hard to implement (?) 2. Quoting identifiers. This is something that we were going to do for =20= some time, but never got around to actually doing it (we have a few =20 Jiras on it). There is a workaround for #2 - use quotes in the modeler for the =20 attribute names. There's no workaround for #1, and this is a bug IMO =20 (and as I said, hopefully not a hard one to fix). If you can open a =20 Jira on that, I'd appreciate it. If not, I can do it myself. Thanks, Andrus On Jan 13, 2009, at 6:21 PM, Javi Peter wrote: > > Hi again, > > I=B4ve been doing some debugging and I think I have found the root of =20= > the problem. In order to do the following debugs I had to edit the =20 > mapping file manually (because the modeler hangs). > > We have to take into account that a query statement for a column =20 > "mail.host" of the table "account" like "SELECT t0.mail.host, =20 > t0.others FROM account t0" will fail, and it must be queried like =20 > "SELECT t0.`mail.host`, t0.others FROM account t0". > > I launched a simple test and it failed with this exception: > > INFO QueryLogger: *** error. > org.apache.cayenne.exp.ExpressionException: [v.2.0.4 October 8 2007] =20= > Can't resolve path component: [account.mail]. > at org.apache.cayenne.map.Entity$PathIterator.next(Entity.java:363) > at =20 > org=20 > .apache=20 > .cayenne=20 > .access=20 > .trans.SelectTranslator.appendQueryColumns(SelectTranslator.java:377) > at =20 > org=20 > .apache=20 > .cayenne=20 > .access=20 > .trans.SelectTranslator.buildResultColumns(SelectTranslator.java:338) > at =20 > org=20 > .apache=20 > .cayenne=20 > .access.trans.SelectTranslator.createSqlString(SelectTranslator.java:=20= > 113) > at =20 > org=20 > .apache=20 > .cayenne=20 > .dba=20 > .mysql=20 > .MySQLSelectTranslator.createSqlString(MySQLSelectTranslator.java:31) > at =20 > org=20 > .apache=20 > .cayenne=20 > .access.trans.QueryAssembler.createStatement(QueryAssembler.java:95) > [...] > > The problem there was a StringTokenizer in =20 > org.apache.cayenne.map.Entity (line 331) which in method next() =20 > thinks that the dot of "mail.host" is another token so it treats it =20= > like two attributes instead of one. Changing manually the variable =20 > on debug mode and changing back again after the tokenizer, it =20 > finally forms the SQL statement, but the bad one, so again we get an =20= > exception: > > com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column =20= > 't0.mail.host' in 'field list' > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1026) > at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515) > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447) > at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951) > at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101) > at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554) > at =20 > com=20 > .mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:=20= > 1761) > [..] > > A search for the root of this exception lead me to =20 > org.apache.cayenne.access.trans.SelectTranslator, where the =20 > ArrayList "colums" gets filled and there it is the ColumnDescriptor =20= > for our column, and the qualifiedColumnName is "t0.mail.host", which =20= > of course won=B4t work. Changing it to "t0.`mail.host`" builds the =20 > correct SELECT statement and finally works. > > Is this a bug or am I missing something? > Javier Rubio > > >> From: javipeter@hotmail.com >> To: user@cayenne.apache.org >> Subject: RE: Modeler Exception for using dots on attributes >> Date: Tue, 13 Jan 2009 09:07:09 +0100 >> >> >> Sure: "account" is the table, "mail.imap.minidletime" is the column =20= >> name. >> >> Thanks in advance >> Javier >> >>> From: andrus@objectstyle.org >>> To: user@cayenne.apache.org >>> Subject: Re: Modeler Exception for using dots on attributes >>> Date: Mon, 12 Jan 2009 19:32:08 +0200 >>> >>> So "account.mail" is a COLUMN name? Not a table + column name? >>> >>> Could you clarify please. >>> >>> Thanks, >>> Andrus >>> >>> >>> On Jan 12, 2009, at 7:10 PM, Javi Peter wrote: >>> >>>> >>>> Hi, >>>> >>>> each time I reverse engineer a database schema with dots (e.g. >>>> "mail.account"), the modeler hangs. If I hit Validate Project, it >>>> shows the exception shown at the end of the email. >>>> It also happens if I create manually the ObjAttribute. >>>> >>>> Any ideas of why this happens and how to workaround this (I MUST =20= >>>> use >>>> dots). >>>> >>>> Thanks, >>>> Javier Rubio >>>> >>>> >>>> CayenneModeler Info >>>> Version: 2.0.4 >>>> Build Date: October 8 2007 >>>> Exception: >>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>>> org.apache.cayenne.exp.ExpressionException: [v.2.0.4 October 8 =20 >>>> 2007] >>>> Can't resolve path component: [account.mail]. >>>> at org.apache.cayenne.map.Entity$PathIterator.next(Entity.java:=20= >>>> 363) >>>> at >>>> org=20 >>>> .apache.cayenne.map.ObjAttribute.getDbAttribute(ObjAttribute.java: >>>> 147) >>>> at >>>> org >>>> .apache >>>> .cayenne >>>> .util.EntityMergeSupport.getMeaningfulFKs(EntityMergeSupport.java:=20= >>>> 173) >>>> at >>>> org >>>> .apache >>>> .cayenne >>>> .modeler >>>> .dialog >>>> .objentity >>>> .EntitySyncController.createMerger(EntitySyncController.java:69) >>>> at >>>> org >>>> .apache >>>> .cayenne >>>> .modeler >>>> .action.DbEntitySyncAction.synchDbEntity(DbEntitySyncAction.java:=20= >>>> 75) >>>> at >>>> org >>>> .apache >>>> .cayenne >>>> .modeler >>>> .action.DbEntitySyncAction.performAction(DbEntitySyncAction.java:=20= >>>> 60) >>>> at >>>> org >>>> .apache >>>> .cayenne >>>> .modeler.util.CayenneAction.actionPerformed(CayenneAction.java:163) >>>> at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) >>>> at javax.swing.AbstractButton$Handler.actionPerformed(Unknown >>>> Source) >>>> at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown >>>> Source) >>>> at javax.swing.DefaultButtonModel.setPressed(Unknown Source) >>>> at >>>> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown >>>> Source) >>>> at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) >>>> at java.awt.Component.processMouseEvent(Unknown Source) >>>> at javax.swing.JComponent.processMouseEvent(Unknown Source) >>>> at java.awt.Component.processEvent(Unknown Source) >>>> at java.awt.Container.processEvent(Unknown Source) >>>> at java.awt.Component.dispatchEventImpl(Unknown Source) >>>> at java.awt.Container.dispatchEventImpl(Unknown Source) >>>> at java.awt.Component.dispatchEvent(Unknown Source) >>>> at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown >>>> Source) >>>> at java.awt.LightweightDispatcher.processMouseEvent(Unknown =20 >>>> Source) >>>> at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) >>>> at java.awt.Container.dispatchEventImpl(Unknown Source) >>>> at java.awt.Window.dispatchEventImpl(Unknown Source) >>>> at java.awt.Component.dispatchEvent(Unknown Source) >>>> at java.awt.EventQueue.dispatchEvent(Unknown Source) >>>> at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown >>>> Source) >>>> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown >>>> Source) >>>> at java.awt.EventDispatchThread.pumpEvents(Unknown Source) >>>> at java.awt.EventDispatchThread.pumpEvents(Unknown Source) >>>> at java.awt.EventDispatchThread.run(Unknown Source) >>>> >>>> >>>> _________________________________________________________________ >>>> Descubre todas las formas en que puedes estar en contacto con =20 >>>> amigos >>>> y familiares. >>>> http://www.microsoft.com/windows/windowslive/default.aspx >>> >> >> _________________________________________________________________ >> Chatea sin l=EDmites en Messenger con la tarifa plana de Orange >> http://serviciosmoviles.es.msn.com/messenger/orange.aspx > > _________________________________________________________________ > =BFQuieres ver los mejores videos de MSN? Enciende Messenger TV > http://messengertv.msn.com/mkt/es-es/default.htm