Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 19445 invoked from network); 23 Sep 2009 19:21:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Sep 2009 19:21:29 -0000 Received: (qmail 74036 invoked by uid 500); 23 Sep 2009 19:21:29 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 73998 invoked by uid 500); 23 Sep 2009 19:21:29 -0000 Mailing-List: contact commits-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list commits@openjpa.apache.org Received: (qmail 73989 invoked by uid 99); 23 Sep 2009 19:21:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2009 19:21:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2009 19:21:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 332FA23888FC; Wed, 23 Sep 2009 19:21:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r818217 - in /openjpa/branches/1.3.x/openjpa-persistence-jdbc/src: main/java/org/apache/openjpa/persistence/jdbc/ test/java/org/apache/openjpa/persistence/jdbc/strategy/ test/resources/META-INF/ Date: Wed, 23 Sep 2009 19:21:04 -0000 To: commits@openjpa.apache.org From: dwoods@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090923192104.332FA23888FC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dwoods Date: Wed Sep 23 19:21:03 2009 New Revision: 818217 URL: http://svn.apache.org/viewvc?rev=818217&view=rev Log: OPENJPA-1116 Annotation Strategy not working. Checking in testcases and code patch already committed in trunk. Patches contributed by Ashish Paliwal. Added: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Address.java (with props) openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/InnerJoinStrategy.java (with props) openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Person.java (with props) openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/TestStrategyAnnotaion.java (with props) Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java?rev=818217&r1=818216&r2=818217&view=diff ============================================================================== --- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java (original) +++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/AnnotationPersistenceMappingParser.java Wed Sep 23 19:21:03 2009 @@ -1134,7 +1134,7 @@ parseOrderColumn(fm, (OrderColumn) anno); break; case STRAT: - fm.getValueInfo().setStrategy(((Strategy) anno).value()); + fm.getMappingInfo().setStrategy(((Strategy) anno).value()); break; case UNIQUE: parseUnique(fm, Added: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Address.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Address.java?rev=818217&view=auto ============================================================================== --- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Address.java (added) +++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Address.java Wed Sep 23 19:21:03 2009 @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.jdbc.strategy; + +import java.util.*; +import javax.persistence.*; + +@Entity +public class Address { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id_address") + private long idAddress; + + @Basic + @Column(nullable = false, length = 30) + private String city; + + + public Address() {} + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public long getIdAddress() { + return idAddress; + } + + public void setIdAddress(long idAddress) { + this.idAddress = idAddress; + } +} + Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Address.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/InnerJoinStrategy.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/InnerJoinStrategy.java?rev=818217&view=auto ============================================================================== --- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/InnerJoinStrategy.java (added) +++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/InnerJoinStrategy.java Wed Sep 23 19:21:03 2009 @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.jdbc.strategy; + +import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration; +import org.apache.openjpa.jdbc.kernel.JDBCStore; +import org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy; +import org.apache.openjpa.jdbc.sql.Select; +import org.apache.openjpa.kernel.OpenJPAStateManager; + +public class InnerJoinStrategy extends RelationFieldStrategy { + public void selectEagerJoin(Select sel, OpenJPAStateManager sm, + JDBCStore store, JDBCFetchConfiguration fetch, int eagerMode) { + + // add field to inner join to make sure that "inner join" is made + // rather than default "left outer join" + fetch.addFetchInnerJoin(field.getFullName(false)); + super.selectEagerJoin(sel, sm, store, fetch, eagerMode); + } +} + Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/InnerJoinStrategy.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Person.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Person.java?rev=818217&view=auto ============================================================================== --- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Person.java (added) +++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Person.java Wed Sep 23 19:21:03 2009 @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.jdbc.strategy; + +import java.util.*; +import javax.persistence.*; + +import org.apache.openjpa.persistence.jdbc.Strategy; +import org.apache.openjpa.persistence.jdbc.Strategy; + +@Entity +public class Person { + + private long idPerson; + + private String name; + + private int age; + + private Address address; + + public Person() {} + + @Basic + @Column(nullable = false) + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Basic + @Column(nullable = false, length = 30) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + @Column(name = "id_person") + public long getIdPerson() { + return idPerson; + } + + public void setIdPerson(long idPerson) { + this.idPerson = idPerson; + } + + @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @Strategy(value = "org.apache.openjpa.persistence.jdbc.strategy.InnerJoinStrategy" ) + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } +} + Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/Person.java ------------------------------------------------------------------------------ svn:eol-style = native Added: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/TestStrategyAnnotaion.java URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/TestStrategyAnnotaion.java?rev=818217&view=auto ============================================================================== --- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/TestStrategyAnnotaion.java (added) +++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/TestStrategyAnnotaion.java Wed Sep 23 19:21:03 2009 @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.jdbc.strategy; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +import junit.framework.TestCase; + +import org.apache.openjpa.persistence.test.SingleEMFTestCase; + + +public class TestStrategyAnnotaion extends SingleEMFTestCase { + public void testStrategy() { + EntityManagerFactory emf = Persistence. + createEntityManagerFactory("testStrategy", System.getProperties()); + EntityManager em = emf.createEntityManager(); + em.getTransaction().begin(); + Person person = new Person(); + person.setName("parul"); + person.setAge(21); + + // no address entered for person. + em.persist(person); + em.getTransaction().commit(); + em.clear(); + + // In case of inner join, the result set should be empty + List pers = em.createQuery("select p from Person p").getResultList(); + assertTrue(pers.isEmpty()); + } +} + Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/strategy/TestStrategyAnnotaion.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml?rev=818217&r1=818216&r2=818217&view=diff ============================================================================== --- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml (original) +++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml Wed Sep 23 19:21:03 2009 @@ -101,4 +101,12 @@ org/apache/openjpa/persistence/annotations/xml/orm.xml + + org.apache.openjpa.persistence.jdbc.strategy.Person + org.apache.openjpa.persistence.jdbc.strategy.Address + + + + +