Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 71335 invoked from network); 6 May 2008 08:18:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 May 2008 08:18:15 -0000 Received: (qmail 96491 invoked by uid 500); 6 May 2008 08:18:16 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 96482 invoked by uid 500); 6 May 2008 08:18: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 96471 invoked by uid 99); 6 May 2008 08:18:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2008 01:18:16 -0700 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 [129.70.204.73] (HELO mux2-unibi-smtp.hrz.uni-bielefeld.de) (129.70.204.73) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2008 08:17:23 +0000 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=UTF-8; format=flowed Received: from pmxchannel-daemon.mux2-unibi-smtp.hrz.uni-bielefeld.de by mux2-unibi-smtp.hrz.uni-bielefeld.de (Sun Java(tm) System Messaging Server 6.3-6.03 (built Mar 14 2008; 32bit)) id <0K0F00200TPHT500@mux2-unibi-smtp.hrz.uni-bielefeld.de> for user@cayenne.apache.org; Tue, 06 May 2008 10:17:41 +0200 (CEST) Received: from [192.168.1.3] ([78.94.54.34]) by mux2-unibi-smtp.hrz.uni-bielefeld.de (Sun Java(tm) System Messaging Server 6.3-6.03 (built Mar 14 2008; 32bit)) with ESMTPPA id <0K0F00KUWTPGDSE0@mux2-unibi-smtp.hrz.uni-bielefeld.de> for user@cayenne.apache.org; Tue, 06 May 2008 10:17:41 +0200 (CEST) Date: Tue, 06 May 2008 10:17:40 +0200 From: Daniel Doppmeier Subject: many-to-many mapping resulting in incomplete SQL queries To: user@cayenne.apache.org Message-id: <48201424.6060504@cebitec.uni-bielefeld.de> X-EnvFrom: ddoppmei@cebitec.uni-bielefeld.de X-PMX-Version: 5.3.3.310218, Antispam-Engine: 2.6.0.325393, Antispam-Data: 2008.5.6.10357, pmx6.hrz.uni-bielefeld.de X-Connecting-IP: 78.94.54.34 User-Agent: Thunderbird 2.0.0.12 (X11/20080227) X-Virus-Checked: Checked by ClamAV on apache.org Hello everyone! I am new to cayenne and experiencing some problems, when modelling a many-to-many relationship. After I could not solve the problem for an application I am writing at the moment, I set up the following example application, which is producing the same problems: I modelled a small bookstore application, with two tables "Book" and "Person". After that I created a join table "Person_is_author_of_book", to map from "Person" entries to "Book" entries. On the object side of the application, this would mean, that every book may have several authors, whereas one author may have written more than one book. Inserting and fetching data from the DB seems to work just fine, but when it comes to deletion there occures my problem. This is what happens in my code: DataContext context = DataContext.createDataContext(); Book book1 = (Book) context.newObject(Book.class); book1.setTitle("The secret life of Donald D"); Person author1 = (Person) context.newObject(Person.class); author1.setName("Huey"); Person author2 = (Person) context.newObject(Person.class); author2.setName("Dewey"); context.commitChanges(); author1.removeFromBooks(book1); context.commitChanges(); Everything is fine until the second commitChanges(), when I try to delete book1 from author1's list. This is what the logger says about it: INFO QueryLogger: --- will run 1 query. INFO QueryLogger: --- transaction started. INFO QueryLogger: DELETE FROM Person_is_author_of_book WHERE INFO QueryLogger: *** error. As you can see, there is missing some SQL syntax after the WHERE clause. Does anybody have an idea, what may cause this malformed SQL? I am using the latest stable cayenne version 2.0.4, MySQL 5.0.51a-3ubuntu5 and java "1.6.0_06" Thanks a lot for any help!