You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2006/11/30 12:41:14 UTC
svn commit: r480897 - in
/incubator/cayenne/main/trunk/integration-test/jpa-chapter2: ./
src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/
src/main/resources/META-INF/
src/test/java/org/apache/cayenne/jpa/itest/ch2/ src/test/resources/
Author: aadamchik
Date: Thu Nov 30 03:41:13 2006
New Revision: 480897
URL: http://svn.apache.org/viewvc?view=rev&rev=480897
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/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/MapFieldPersistenceEntity.java
Modified:
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/.classpath
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/CollectionFieldPersistenceEntity.java
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/FieldPersistenceEntity.java
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity1.java
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity4.java
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/resources/META-INF/persistence.xml
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_1_PeristentFieldsAndPropertiesTest.java
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_4_PrimaryKeyAndIdentityTest.java
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_7_EntityRelationshipsTest.java
incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/resources/schema-hsqldb.sql
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/.classpath
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/.classpath?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/.classpath (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/.classpath Thu Nov 30 03:41:13 2006
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
- <classpathentry output="target/test-classes" kind="src" path="src/test/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
<classpathentry excluding="**" output="src/main/resources" kind="src" path="src/main/resources"/>
<classpathentry excluding="**" output="src/test/resources" kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/CollectionFieldPersistenceEntity.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/CollectionFieldPersistenceEntity.java?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/CollectionFieldPersistenceEntity.java (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/CollectionFieldPersistenceEntity.java Thu Nov 30 03:41:13 2006
@@ -20,7 +20,6 @@
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.persistence.Entity;
@@ -42,9 +41,6 @@
@OneToMany
protected List<HelperEntity3> list;
- @OneToMany
- protected Map<Object, HelperEntity4> map;
-
public Collection<HelperEntity1> getCollection() {
return collection;
}
@@ -59,14 +55,6 @@
public void setList(List<HelperEntity3> list) {
this.list = list;
- }
-
- public Map<Object, HelperEntity4> getMap() {
- return map;
- }
-
- public void setMap(Map<Object, HelperEntity4> map) {
- this.map = map;
}
public Set<HelperEntity2> getSet() {
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/FieldPersistenceEntity.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/FieldPersistenceEntity.java?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/FieldPersistenceEntity.java (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/FieldPersistenceEntity.java Thu Nov 30 03:41:13 2006
@@ -40,4 +40,8 @@
throw new RuntimeException(
"setter is not supposed to be called in case of field based persistence");
}
+
+ public int idField() {
+ return id;
+ }
}
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity1.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity1.java?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity1.java (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity1.java Thu Nov 30 03:41:13 2006
@@ -30,4 +30,8 @@
@ManyToOne
protected CollectionFieldPersistenceEntity entity;
+
+ public CollectionFieldPersistenceEntity getEntity() {
+ return entity;
+ }
}
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity4.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity4.java?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity4.java (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/HelperEntity4.java Thu Nov 30 03:41:13 2006
@@ -29,5 +29,5 @@
protected int id;
@ManyToOne
- protected CollectionFieldPersistenceEntity entity;
+ protected MapFieldPersistenceEntity entity;
}
Added: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/MapFieldPersistenceEntity.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/MapFieldPersistenceEntity.java?view=auto&rev=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/MapFieldPersistenceEntity.java (added)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/java/org/apache/cayenne/jpa/itest/ch2/entity/MapFieldPersistenceEntity.java Thu Nov 30 03:41:13 2006
@@ -0,0 +1,43 @@
+/*****************************************************************
+ * 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.jpa.itest.ch2.entity;
+
+import java.util.Map;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+@Entity
+public class MapFieldPersistenceEntity {
+
+ @Id
+ protected int id;
+
+ @OneToMany
+ protected Map<Object, HelperEntity4> map;
+
+ public Map<Object, HelperEntity4> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<Object, HelperEntity4> map) {
+ this.map = map;
+ }
+}
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/resources/META-INF/persistence.xml?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/resources/META-INF/persistence.xml (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/main/resources/META-INF/persistence.xml Thu Nov 30 03:41:13 2006
@@ -25,6 +25,7 @@
<class>org.apache.cayenne.jpa.itest.ch2.entity.PropertyPersistenceEntity</class>
<class>org.apache.cayenne.jpa.itest.ch2.entity.TransientFieldsEntity</class>
<class>org.apache.cayenne.jpa.itest.ch2.entity.CollectionFieldPersistenceEntity</class>
+ <class>org.apache.cayenne.jpa.itest.ch2.entity.MapFieldPersistenceEntity</class>
<class>org.apache.cayenne.jpa.itest.ch2.entity.HelperEntity1</class>
<class>org.apache.cayenne.jpa.itest.ch2.entity.HelperEntity2</class>
<class>org.apache.cayenne.jpa.itest.ch2.entity.HelperEntity3</class>
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_1_PeristentFieldsAndPropertiesTest.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_1_PeristentFieldsAndPropertiesTest.java?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_1_PeristentFieldsAndPropertiesTest.java (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_1_PeristentFieldsAndPropertiesTest.java Thu Nov 30 03:41:13 2006
@@ -27,6 +27,7 @@
import org.apache.cayenne.jpa.itest.ch2.entity.HelperEntity2;
import org.apache.cayenne.jpa.itest.ch2.entity.HelperEntity3;
import org.apache.cayenne.jpa.itest.ch2.entity.HelperEntity4;
+import org.apache.cayenne.jpa.itest.ch2.entity.MapFieldPersistenceEntity;
import org.apache.cayenne.jpa.itest.ch2.entity.PropertyPersistenceEntity;
import org.apache.cayenne.jpa.itest.ch2.entity.TransientFieldsEntity;
@@ -66,6 +67,14 @@
o1.setCollection(Collections.singleton(new HelperEntity1()));
o1.setSet(Collections.singleton(new HelperEntity2()));
o1.setList(Collections.singletonList(new HelperEntity3()));
+
+ getEntityManager().persist(o1);
+ getEntityManager().getTransaction().commit();
+ }
+
+ // TODO: andrus 8/30/2006 - fails
+ public void _testMapProperties() {
+ MapFieldPersistenceEntity o1 = new MapFieldPersistenceEntity();
o1.setMap(Collections.singletonMap(new Object(), new HelperEntity4()));
getEntityManager().persist(o1);
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_4_PrimaryKeyAndIdentityTest.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_4_PrimaryKeyAndIdentityTest.java?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_4_PrimaryKeyAndIdentityTest.java (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_4_PrimaryKeyAndIdentityTest.java Thu Nov 30 03:41:13 2006
@@ -51,8 +51,15 @@
}
public void testSimplePk() throws Exception {
+ getDbHelper().deleteAll("FieldPersistenceEntity");
+
FieldPersistenceEntity o1 = new FieldPersistenceEntity();
getEntityManager().persist(o1);
+
+ assertEquals(0, o1.idField());
+ getEntityManager().getTransaction().commit();
+ assertTrue(o1.idField() > 0);
+ assertEquals(o1.idField(), getDbHelper().getInt("FieldPersistenceEntity", "id"));
}
// TODO: andrus 8/10/2006 - fails
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_7_EntityRelationshipsTest.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_7_EntityRelationshipsTest.java?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_7_EntityRelationshipsTest.java (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/java/org/apache/cayenne/jpa/itest/ch2/_2_1_7_EntityRelationshipsTest.java Thu Nov 30 03:41:13 2006
@@ -23,14 +23,7 @@
public class _2_1_7_EntityRelationshipsTest extends EntityManagerCase {
- // TODO: andrus 8/10/2006 - placeholder test, as there are no succeeding tests in this
- // class yet.
- public void testDummy() {
-
- }
-
- // TODO: andrus 8/10/2006 - fails because of pk handling issues
- public void _testEmptyCollection() throws Exception {
+ public void testEmptyCollection() throws Exception {
getDbHelper().deleteAll("HelperEntity1");
getDbHelper().deleteAll("CollectionFieldPersistenceEntity");
@@ -49,7 +42,7 @@
}
// TODO: andrus 8/10/2006 - fails because of pk handling issues
- public void _testNonEmptyCollection() throws Exception {
+ public void testNonEmptyCollection() throws Exception {
getDbHelper().deleteAll("HelperEntity1");
getDbHelper().deleteAll("CollectionFieldPersistenceEntity");
Modified: incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/resources/schema-hsqldb.sql
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/resources/schema-hsqldb.sql?view=diff&rev=480897&r1=480896&r2=480897
==============================================================================
--- incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/resources/schema-hsqldb.sql (original)
+++ incubator/cayenne/main/trunk/integration-test/jpa-chapter2/src/test/resources/schema-hsqldb.sql Thu Nov 30 03:41:13 2006
@@ -3,6 +3,7 @@
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('PropertyPersistenceEntity', 1);
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('TransientFieldsEntity', 1);
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('CollectionFieldPersistenceEntity', 1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('MapFieldPersistenceEntity', 1);
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('HelperEntity1', 1);
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('HelperEntity2', 1);
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('HelperEntity3', 1);
@@ -20,6 +21,7 @@
create table PropertyPersistenceEntity (id int not null, property1 VARCHAR(100), property2 BOOLEAN, primary key(id));
create table TransientFieldsEntity (id int not null, property1 VARCHAR(100), primary key(id));
create table CollectionFieldPersistenceEntity (id int not null, primary key(id));
+create table MapFieldPersistenceEntity (id int not null, primary key(id));
create table HelperEntity1 (id int not null, entity_id int, primary key(id));
create table HelperEntity2 (id int not null, entity_id int, primary key(id));
create table HelperEntity3 (id int not null, entity_id int, primary key(id));