Author: aadamchik Date: Thu Nov 30 03:40:36 2006 New Revision: 480895 URL: http://svn.apache.org/viewvc?view=rev&rev=480895 Log: CAY-713: Improved Meaningful PK support (CAY-713 accomplished + switching JPA enhancer to the new generic pojo enhancement code + uncommenting a number of JPA relationship itests that work now with the new enhancer)
Added: incubator/cayenne/main/trunk/integration-test/pojo/src/main/java/org/apache/cayenne/itest/pojo/ExposedPkEntity1.java incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/ExposedPkTest.java Modified: incubator/cayenne/main/trunk/integration-test/pojo/src/main/resources/pojo-map.map.xml Added: incubator/cayenne/main/trunk/integration-test/pojo/src/main/java/org/apache/cayenne/itest/pojo/ExposedPkEntity1.java URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/pojo/src/main/java/org/apache/cayenne/itest/pojo/ExposedPkEntity1.java?view=auto&rev=480895 ============================================================================== --- incubator/cayenne/main/trunk/integration-test/pojo/src/main/java/org/apache/cayenne/itest/pojo/ExposedPkEntity1.java (added) +++ incubator/cayenne/main/trunk/integration-test/pojo/src/main/java/org/apache/cayenne/itest/pojo/ExposedPkEntity1.java Thu Nov 30 03:40:36 2006 @@ -0,0 +1,41 @@ +/***************************************************************** + * 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.cayenne.itest.pojo; + +public class ExposedPkEntity1 { + + protected int pk; + protected String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getPk() { + return pk; + } + + public void setPk(int pk) { + this.pk = pk; + } +} Modified: incubator/cayenne/main/trunk/integration-test/pojo/src/main/resources/pojo-map.map.xml URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/pojo/src/main/resources/pojo-map.map.xml?view=diff&rev=480895&r1=480894&r2=480895 ============================================================================== --- incubator/cayenne/main/trunk/integration-test/pojo/src/main/resources/pojo-map.map.xml (original) +++ incubator/cayenne/main/trunk/integration-test/pojo/src/main/resources/pojo-map.map.xml Thu Nov 30 03:40:36 2006 @@ -5,6 +5,10 @@ <db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/> <db-attribute name="name" type="VARCHAR" length="100"/> </db-entity> + <db-entity name="exposed_pk_entity1"> + <db-attribute name="name" type="VARCHAR" length="100"/> + <db-attribute name="pk" type="INTEGER" isPrimaryKey="true" isMandatory="true"/> + </db-entity> <db-entity name="many_to_one_entity1"> <db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/> <db-attribute name="one_to_many_entity1_id" type="INTEGER"/> @@ -14,6 +18,10 @@ </db-entity> <obj-entity name="Entity1" className="org.apache.cayenne.itest.pojo.Entity1" dbEntityName="entity1"> <obj-attribute name="name" type="java.lang.String" db-attribute-path="name"/> + </obj-entity> + <obj-entity name="ExposedPkEntity1" className="org.apache.cayenne.itest.pojo.ExposedPkEntity1" dbEntityName="exposed_pk_entity1"> + <obj-attribute name="name" type="java.lang.String" db-attribute-path="name"/> + <obj-attribute name="pk" type="java.lang.Integer" db-attribute-path="pk"/> </obj-entity> <obj-entity name="ManyToOneEntity1" className="org.apache.cayenne.itest.pojo.ManyToOneEntity1" dbEntityName="many_to_one_entity1"> </obj-entity> Added: incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/ExposedPkTest.java URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/ExposedPkTest.java?view=auto&rev=480895 ============================================================================== --- incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/ExposedPkTest.java (added) +++ incubator/cayenne/main/trunk/integration-test/pojo/src/test/java/org/apache/cayenne/itest/pojo/ExposedPkTest.java Thu Nov 30 03:40:36 2006 @@ -0,0 +1,38 @@ +/***************************************************************** + * 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.cayenne.itest.pojo; + +import org.apache.cayenne.DataObjectUtils; + +public class ExposedPkTest extends PojoContextCase { + + public void testGenerated() throws Exception { + ExposedPkEntity1 o1 = (ExposedPkEntity1) context + .newObject(ExposedPkEntity1.class); + o1.setName("a"); + + assertEquals(0, o1.getPk()); + + context.commitChanges(); + assertTrue(o1.getPk() > 0); + + assertSame(o1, DataObjectUtils.objectForPK(context, ExposedPkEntity1.class, o1 + .getPk())); + } +}