Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2D76A10C61 for ; Sat, 12 Sep 2015 12:48:22 +0000 (UTC) Received: (qmail 92195 invoked by uid 500); 12 Sep 2015 12:48:22 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 92164 invoked by uid 500); 12 Sep 2015 12:48:21 -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 92151 invoked by uid 99); 12 Sep 2015 12:48:21 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Sep 2015 12:48:21 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 419A51A1803 for ; Sat, 12 Sep 2015 12:48:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.001 X-Spam-Level: *** X-Spam-Status: No, score=3.001 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id GLnRIDOHr-D4 for ; Sat, 12 Sep 2015 12:48:12 +0000 (UTC) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 5587E4414C for ; Sat, 12 Sep 2015 12:48:12 +0000 (UTC) Received: by wiclk2 with SMTP id lk2so91335189wic.0 for ; Sat, 12 Sep 2015 05:48:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=djxwVut66G/h3ZNfmFi2OfI5wzSZOJLKmkZYhzkLYlM=; b=jpc2CDMzEum6PyeZVyeRpFV4nWXK8CggZPxWH/3oIHroREFf1GVFz/wJFRO81UIV31 zPb4id2FYrNJ2PUpG7pfO/XBac4PkhS+LZDSvz3Bz7d6/zB0gzD1t1RKr96eO8Keg1Us BV3VG/y3XAIC4qmOQtHsix2s51qoxqmcbK4lQomG2q3EMl+rYLZPfEdM3zSvGbn+dhcD xG/oSykGiDN32KEjdKi88bQYpYIJOHovBX2JfCEIC9tMKrzATv1DHJ9yypB1UTLCe1e+ Wlgn6UxOF2CVb/DI0exp3LJlFcibf4d6TYjtZdMIQRipyoXf2tkWRjzaCZiws41RoJId pwTQ== X-Gm-Message-State: ALoCoQk0EYKDBqBeM0WRXD2QoL5XUlPX83mnw9jSexH9UmgWdLsMqKzWuvjt5EClobvwGwEcxWXy MIME-Version: 1.0 X-Received: by 10.194.192.166 with SMTP id hh6mr7271203wjc.127.1442062091452; Sat, 12 Sep 2015 05:48:11 -0700 (PDT) Received: by 10.194.209.163 with HTTP; Sat, 12 Sep 2015 05:48:11 -0700 (PDT) X-Originating-IP: [27.5.102.145] In-Reply-To: References: Date: Sat, 12 Sep 2015 18:18:11 +0530 Message-ID: Subject: Re: Query at the time of inserting data using Apache Cayenne From: Dipesh Jain To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=047d7bb70950b498e8051f8c3ed7 --047d7bb70950b498e8051f8c3ed7 Content-Type: text/plain; charset=UTF-8 Thanks @Andrus for the help. I am using CayenneFilter session-scoped context, because of that I was having problem. I saw your solution but I am using cayenne 3.1 and it does not have StatelessContextRequestHandler class. My entire project is based on Web Services so is there any other way I can use request-scoped context with connection pooling or do you have any other alternative better then this ? On Fri, Sep 11, 2015 at 7:46 PM, Dipesh Jain wrote: > I have tried to implement @Aristedes Maniatis answer but still result was > same. I want to know why and how apache cayenne is doing this. I do not > want the solution because I already have the answer. > > On Wed, Sep 9, 2015 at 9:41 PM, Dipesh Jain wrote: > >> I have written a code in java 8 to insert data in sql server 2012 using >> apache cayenne 3.1. While executing code I got an exception : >> **org.apache.cayenne.CayenneRuntimeException: [v.3.1 Sep 20 2014 14:24:57] >> Commit Exception Caused by: java.sql.SQLException: Could not find stored >> procedure 'auto_pk_for_table'**. >> >> I have solved the problem by changing my pk generation strategy in >> cayenne modeler from default to database generated. But when I executed my >> java code again, it was suppose to insert only 1 record in database but it >> also inserted previous record which I got in exception. I have tried >> creating the same scenario thrice but I got the same result. I also tried >> restarting my web server and SQL server service after getting an exception, >> but at the time of inserting new data exceptional record was also been >> inserted at the same time. >> This Problem is also solved by inserting a rollback statement in my catch >> block. >> >> But I want to know that how and why is apache cayenne inserting >> exceptional data at the time of inserting new data. >> >> This is my code. >> **Java :** >> PersonDao >> >> try { >> Person person = new Person(); >> person.setFirstName("John"); >> person.setLastName("Cross"); >> ObjectContext context = BaseContext.getThreadObjectContext(); >> context.registerNewObject(person); >> context.commitChanges(); >> } catch (CayenneRuntimeException e) { >> context.rollbackChanges(); >> throw e; >> } >> >> **XML files :** >> cayenne-test.xml >> >> >> >> > value="true"/> >> >> > factory="org.apache.cayenne.configuration.server.XMLPoolingDataSourceFactory" >> schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy"> >> >> >> >> >> >> >> >> >> >> >> TestDataMap.map.xml >> >> >> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> xsi:schemaLocation="http://cayenne.apache.org/schema/3.0/modelMap >> http://cayenne.apache.org/schema/3.0/modelMap.xsd" >> project-version="6"> >> >> >> > isGenerated="true" isMandatory="true" length="10"/> >> >> >> >> > className="com.org.ivcargo.platform.dto.PersonTemp" >> dbEntityName="PersonTemp"> >> > db-attribute-path="personId"/> >> > db-attribute-path="firstname"/> >> > db-attribute-path="lastname"/> >> >> >> >> -- >> Thanks and Regards >> Deepesh Jain >> > > > > -- > Thanks and Regards > Deepesh Jain > -- Thanks and Regards Deepesh Jain --047d7bb70950b498e8051f8c3ed7--