Author: aadamchik
Date: Mon Sep 4 02:02:45 2006
New Revision: 439986
URL: http://svn.apache.org/viewvc?view=rev&rev=439986
Log:
itest chapter 2.1.8.1 - bidirectional one-to-one defaults
Added:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwned.java
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwner.java
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_8_1_BidiOneToOneRelationshipsTest.java
Modified:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql
Added:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwned.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwned.java?view=auto&rev=439986
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwned.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwned.java
Mon Sep 4 02:02:45 2006
@@ -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.cayenne.jpa.itest1.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+
[EMAIL PROTECTED]
+public class BidiOneToOneOwned {
+
+ @Id
+ protected int id;
+
+ @OneToOne(mappedBy = "owned")
+ protected BidiOneToOneOwner owner;
+
+ public BidiOneToOneOwner getOwner() {
+ return owner;
+ }
+}
Added:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwner.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwner.java?view=auto&rev=439986
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwner.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/java/org/apache/cayenne/jpa/itest1/entity/BidiOneToOneOwner.java
Mon Sep 4 02:02:45 2006
@@ -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.cayenne.jpa.itest1.entity;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+
[EMAIL PROTECTED]
+public class BidiOneToOneOwner {
+
+ @Id
+ protected int id;
+
+ @OneToOne
+ protected BidiOneToOneOwned owned;
+
+ public BidiOneToOneOwned getOwned() {
+ return owned;
+ }
+}
Modified:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml?view=diff&rev=439986&r1=439985&r2=439986
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml
(original)
+++
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/main/resources/META-INF/persistence.xml
Mon Sep 4 02:02:45 2006
@@ -39,5 +39,7 @@
<class>org.apache.cayenne.jpa.itest1.entity.PropertyDefaultsDatesEntity</class>
<class>org.apache.cayenne.jpa.itest1.entity.PropertyDefaultsOtherEntity</class>
<class>org.apache.cayenne.jpa.itest1.entity.PropertyDefaultsInvalidEntity</class>
+
<class>org.apache.cayenne.jpa.itest1.entity.BidiOneToOneOwner</class>
+
<class>org.apache.cayenne.jpa.itest1.entity.BidiOneToOneOwned</class>
</persistence-unit>
</persistence>
Added:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_8_1_BidiOneToOneRelationshipsTest.java
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_8_1_BidiOneToOneRelationshipsTest.java?view=auto&rev=439986
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_8_1_BidiOneToOneRelationshipsTest.java
(added)
+++
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/java/org/apache/cayenne/jpa/itest/entity/_2_1_8_1_BidiOneToOneRelationshipsTest.java
Mon Sep 4 02:02:45 2006
@@ -0,0 +1,60 @@
+/*****************************************************************
+ * 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.entity;
+
+import org.apache.cayenne.jpa.itest.EntityManagerCase;
+import org.apache.cayenne.jpa.itest.ItestDBUtils;
+import org.apache.cayenne.jpa.itest1.entity.BidiOneToOneOwned;
+import org.apache.cayenne.jpa.itest1.entity.BidiOneToOneOwner;
+
+public class _2_1_8_1_BidiOneToOneRelationshipsTest 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
+ public void _testDefaults() throws Exception {
+ ItestDBUtils.deleteAll("BidiOneToOneOwned");
+ ItestDBUtils.deleteAll("BidiOneToOneOwner");
+
+ ItestDBUtils.insert("BidiOneToOneOwned", new String[] {
+ "id"
+ }, new Object[] {
+ 5
+ });
+
+ ItestDBUtils.insert("BidiOneToOneOwner", new String[] {
+ "id", "owned_id"
+ }, new Object[] {
+ 4, 5
+ });
+
+ BidiOneToOneOwner owner =
getEntityManager().find(BidiOneToOneOwner.class, 4);
+ assertNotNull(owner);
+
+ BidiOneToOneOwned owned =
getEntityManager().find(BidiOneToOneOwned.class, 5);
+ assertNotNull(owned);
+
+ assertSame(owned, owner.getOwned());
+ assertSame(owner, owned.getOwner());
+ }
+}
Modified:
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql
URL:
http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql?view=diff&rev=439986&r1=439985&r2=439986
==============================================================================
---
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql
(original)
+++
incubator/cayenne/main/trunk/integration-test/jpa-unit1/src/test/resources/unit1-schema-hsqldb.sql
Mon Sep 4 02:02:45 2006
@@ -13,6 +13,8 @@
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES
('PropertyDefaultsWrapperEntity', 1);
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES
('PropertyDefaultsDatesEntity', 1);
insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES
('PropertyDefaultsOtherEntity', 1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('BidiOneToOneOwner',
1);
+insert into AUTO_PK_SUPPORT (TABLE_NAME, NEXT_ID) VALUES ('BidiOneToOneOwned',
1);
create table FieldPersistenceEntity (id int not null, property1 VARCHAR(100),
primary key(id));
create table PropertyPersistenceEntity (id int not null, property1
VARCHAR(100), property2 BOOLEAN, primary key(id));
@@ -30,4 +32,8 @@
create table PropertyDefaultsPrimitiveEntity (id INT not null,
primitiveBoolean BOOLEAN, primitiveByte TINYINT, primitiveShort SMALLINT,
primitiveChar CHAR(1), primitiveInt INT, primitiveLong BIGINT, primitiveFloat
FLOAT, primitiveDouble DOUBLE, primary key(id));
create table PropertyDefaultsWrapperEntity (id INT not null, booleanWrapper
BOOLEAN, byteWrapper TINYINT, shortWrapper SMALLINT, intWrapper INT,
charWrapper CHAR(1), longWrapper BIGINT, floatWrapper FLOAT, doubleWrapper
DOUBLE, primary key(id));
create table PropertyDefaultsDatesEntity (id int not null, utilDate TIMESTAMP,
calendar TIMESTAMP, sqlDate DATE, sqlTime TIME, sqlTimestamp TIMESTAMP, primary
key(id));
-create table PropertyDefaultsOtherEntity (id int not null, string
VARCHAR(100), bigInt BIGINT, bigDecimal NUMERIC, byteArray VARBINARY(100),
byteWrapperArray VARBINARY(100), charArray VARCHAR(100), charWrapperArray
VARCHAR(100), enumType INT, serializableType VARBINARY(200), primary key(id));
\ No newline at end of file
+create table PropertyDefaultsOtherEntity (id int not null, string
VARCHAR(100), bigInt BIGINT, bigDecimal NUMERIC, byteArray VARBINARY(100),
byteWrapperArray VARBINARY(100), charArray VARCHAR(100), charWrapperArray
VARCHAR(100), enumType INT, serializableType VARBINARY(200), primary key(id));
+create table BidiOneToOneOwned (id int not null, primary key(id));
+create table BidiOneToOneOwner (id int not null, owned_id int not null,
primary key(id));
+alter table BidiOneToOneOwner add constraint cfk_owned_id FOREIGN KEY
(owned_id) references BidiOneToOneOwned (id);
+alter table BidiOneToOneOwner add constraint cu_owned_id UNIQUE (owned_id);