You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2010/02/12 18:54:34 UTC
svn commit: r909532 - in
/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable:
Contractor.java Department.java Employee.java Person.java
TestInheritanceTypeJoinedQuery.java
Author: mikedd
Date: Fri Feb 12 17:54:33 2010
New Revision: 909532
URL: http://svn.apache.org/viewvc?rev=909532&view=rev
Log:
OPENJPA-1401:
setting svn:eol-style native
Modified:
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Contractor.java (contents, props changed)
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Department.java (contents, props changed)
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Employee.java (contents, props changed)
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Person.java (contents, props changed)
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/TestInheritanceTypeJoinedQuery.java (contents, props changed)
Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Contractor.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Contractor.java?rev=909532&r1=909531&r2=909532&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Contractor.java (original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Contractor.java Fri Feb 12 17:54:33 2010
@@ -1,81 +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.inheritance.jointable;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-
-import org.apache.openjpa.persistence.jdbc.Index;
-
-@Inheritance(strategy=InheritanceType.JOINED)
-@Entity
-@Table(name="WContractor")
-public class Contractor extends Employee {
- @Column(name="ContractorProp1",length=10)
- @Basic
- private String ctrProp1;
-
-
- @ManyToOne(optional=true,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH},fetch=FetchType.LAZY)
- @JoinColumn(name="Dept_No",referencedColumnName="OID")
- @Index
- private Department dept;
-
- public Contractor() {
- }
-
- public Contractor(String desc) {
- setDescription(desc);
- }
-
- public String getCtrProp1() {
- return ctrProp1;
- }
-
- public void setCtrProp1(String ctrProp1) {
- this.ctrProp1 = ctrProp1;
- }
-
- public Department getDept() {
- return dept;
- }
-
- public void setDept(Department dept) {
- this.dept = dept;
- }
-
- public boolean equals(Object other) {
- if (other instanceof Contractor) {
- Contractor c = (Contractor) other;
- if (c.getOID() == this.getOID() &&
- c.getDept() == this.getDept())
- return true;
- }
- return false;
- }
-}
-
+/*
+ * 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.inheritance.jointable;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.jdbc.Index;
+
+@Inheritance(strategy=InheritanceType.JOINED)
+@Entity
+@Table(name="WContractor")
+public class Contractor extends Employee {
+ @Column(name="ContractorProp1",length=10)
+ @Basic
+ private String ctrProp1;
+
+
+ @ManyToOne(optional=true,cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH},fetch=FetchType.LAZY)
+ @JoinColumn(name="Dept_No",referencedColumnName="OID")
+ @Index
+ private Department dept;
+
+ public Contractor() {
+ }
+
+ public Contractor(String desc) {
+ setDescription(desc);
+ }
+
+ public String getCtrProp1() {
+ return ctrProp1;
+ }
+
+ public void setCtrProp1(String ctrProp1) {
+ this.ctrProp1 = ctrProp1;
+ }
+
+ public Department getDept() {
+ return dept;
+ }
+
+ public void setDept(Department dept) {
+ this.dept = dept;
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof Contractor) {
+ Contractor c = (Contractor) other;
+ if (c.getOID() == this.getOID() &&
+ c.getDept() == this.getDept())
+ return true;
+ }
+ return false;
+ }
+}
+
Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Contractor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Department.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Department.java?rev=909532&r1=909531&r2=909532&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Department.java (original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Department.java Fri Feb 12 17:54:33 2010
@@ -1,92 +1,92 @@
-/*
- * 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.inheritance.jointable;
-
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-
-@Inheritance(strategy=InheritanceType.JOINED)
-@Entity
-@Table(name="WDept")
-public class Department {
- @Id
- @GeneratedValue(strategy=GenerationType.TABLE, generator="JWTGen")
- private long OID;
-
- @Basic
- private String description;
-
- @Column(name="DeptProp1",length=10)
- @Basic
- private String deptProp1;
-
- @OneToMany(mappedBy="dept",cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH},fetch=FetchType.LAZY)
- private java.util.Collection<Contractor> ctrs;
-
- public Department() {
- }
-
- public Department(String desc) {
- setDescription(desc);
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getDescription() {
- return description;
- }
-
- public long getOID() {
- return OID;
- }
-
- public void setOID(long oid) {
- this.OID = oid;
- }
-
-
- public String getDeptProp1() {
- return deptProp1;
- }
-
- public void setDeptProp1(String deptProp1) {
- this.deptProp1 = deptProp1;
- }
-
- public java.util.Collection<Contractor> getCtrs() {
- return ctrs;
- }
-
- public void setCtrs(java.util.Collection<Contractor> ctrs) {
- this.ctrs = ctrs;
- }
-}
-
+/*
+ * 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.inheritance.jointable;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Inheritance(strategy=InheritanceType.JOINED)
+@Entity
+@Table(name="WDept")
+public class Department {
+ @Id
+ @GeneratedValue(strategy=GenerationType.TABLE, generator="JWTGen")
+ private long OID;
+
+ @Basic
+ private String description;
+
+ @Column(name="DeptProp1",length=10)
+ @Basic
+ private String deptProp1;
+
+ @OneToMany(mappedBy="dept",cascade={CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH},fetch=FetchType.LAZY)
+ private java.util.Collection<Contractor> ctrs;
+
+ public Department() {
+ }
+
+ public Department(String desc) {
+ setDescription(desc);
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public long getOID() {
+ return OID;
+ }
+
+ public void setOID(long oid) {
+ this.OID = oid;
+ }
+
+
+ public String getDeptProp1() {
+ return deptProp1;
+ }
+
+ public void setDeptProp1(String deptProp1) {
+ this.deptProp1 = deptProp1;
+ }
+
+ public java.util.Collection<Contractor> getCtrs() {
+ return ctrs;
+ }
+
+ public void setCtrs(java.util.Collection<Contractor> ctrs) {
+ this.ctrs = ctrs;
+ }
+}
+
Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Department.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Employee.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Employee.java?rev=909532&r1=909531&r2=909532&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Employee.java (original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Employee.java Fri Feb 12 17:54:33 2010
@@ -1,47 +1,47 @@
-/*
- * 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.inheritance.jointable;
-
-import javax.persistence.Basic;
-import javax.persistence.Entity;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Table;
-
-@Entity
-@Table(name="WEmployee")
-@Inheritance(strategy=InheritanceType.JOINED)
-public abstract class Employee extends Person {
-
- @Basic
- private String description;
-
- public Employee() {
- }
-
- public void setDescription(String description) {
- this.description = description;
- super.setName("Name "+description);
- }
-
- public String getDescription() {
- return description;
- }
-}
-
+/*
+ * 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.inheritance.jointable;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="WEmployee")
+@Inheritance(strategy=InheritanceType.JOINED)
+public abstract class Employee extends Person {
+
+ @Basic
+ private String description;
+
+ public Employee() {
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ super.setName("Name "+description);
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
+
Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Employee.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Person.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Person.java?rev=909532&r1=909531&r2=909532&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Person.java (original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Person.java Fri Feb 12 17:54:33 2010
@@ -1,64 +1,64 @@
-/*
- * 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.inheritance.jointable;
-
-import javax.persistence.Basic;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-
-@Entity
-@Table(name="WPerson")
-@Inheritance(strategy=InheritanceType.JOINED)
-@TableGenerator(name="JWTGen", table="JWT_GEN", pkColumnName="PK",
- valueColumnName="ID")
-
-public abstract class Person {
- @Id
- @GeneratedValue(strategy=GenerationType.TABLE, generator="JWTGen")
- private long OID;
-
- @Basic
- private String name;
-
- public Person() {
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public long getOID() {
- return OID;
- }
-
- public void setOID(long oid) {
- this.OID = oid;
- }
-}
-
+/*
+ * 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.inheritance.jointable;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+@Entity
+@Table(name="WPerson")
+@Inheritance(strategy=InheritanceType.JOINED)
+@TableGenerator(name="JWTGen", table="JWT_GEN", pkColumnName="PK",
+ valueColumnName="ID")
+
+public abstract class Person {
+ @Id
+ @GeneratedValue(strategy=GenerationType.TABLE, generator="JWTGen")
+ private long OID;
+
+ @Basic
+ private String name;
+
+ public Person() {
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public long getOID() {
+ return OID;
+ }
+
+ public void setOID(long oid) {
+ this.OID = oid;
+ }
+}
+
Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/Person.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/TestInheritanceTypeJoinedQuery.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/TestInheritanceTypeJoinedQuery.java?rev=909532&r1=909531&r2=909532&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/TestInheritanceTypeJoinedQuery.java (original)
+++ openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/TestInheritanceTypeJoinedQuery.java Fri Feb 12 17:54:33 2010
@@ -1,159 +1,159 @@
-/*
- * 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.inheritance.jointable;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.openjpa.persistence.test.SQLListenerTestCase;
-
-
-public class TestInheritanceTypeJoinedQuery extends SQLListenerTestCase {
-
- public void setUp() {
- setUp(Contractor.class, Employee.class, Department.class, Person.class,
- CLEAR_TABLES);
- populate();
- }
-
- public void populate() {
- EntityManager em = emf.createEntityManager();
-
- Department d = new Department("IT");
- for (int i = 0; i < 3; i++) {
- Contractor c = new Contractor("ctr" + i);
- c.setDept(d);
- em.persist(c);
- }
- em.persist(d);
-
- em.getTransaction().begin();
- em.getTransaction().commit();
- em.close();
- }
-
- public void testInheritanceTypeJoinedQuery() {
- EntityManager em = emf.createEntityManager();
- Query q = null;
- String qS = null;
- Department dept = null;
-
- qS = "SELECT c.OID, c.dept FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- List<Object[]> lResult = q.getResultList();
- for (Object[] resultElement : lResult) {
- Long oid = (Long)resultElement[0];
- dept = (Department)resultElement[1];
- }
-
- qS = "SELECT c.OID FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- for (Object resultElement : q.getResultList()) {
- Long oid = (Long)resultElement;
- }
-
- qS = "SELECT d FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- for (Department aResult: (List <Department>) q.getResultList()) {
- assertEquals(dept.getOID(), aResult.getOID());
- }
-
- qS = "SELECT c FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- for (Contractor aResult: (List <Contractor>) q.getResultList()) {
- //System.out.println(aResult.getDescription() + ", " + aResult.getOID());
- assertEquals(dept.getOID(), aResult.getDept().getOID());
- }
- qS = "SELECT c FROM Contractor c, Department d where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- for (Contractor aResult: (List <Contractor>) q.getResultList()) {
- assertEquals(dept.getOID(), aResult.getDept().getOID());
- }
-
- qS = "SELECT c, c.OID FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- List<Object[]> cResult = q.getResultList();
- Contractor contractor = null;
- for (Object[] resultElement : cResult) {
- contractor = (Contractor)resultElement[0];
- Long oid = (Long)resultElement[1];
- assertTrue(contractor.getOID() == oid);
- assertEquals(dept.getOID(), contractor.getDept().getOID());
- }
-
- qS = "SELECT c.OID, c FROM Contractor c, Department d where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- List<Object[]> dResult = q.getResultList();
- for (Object[] resultElement : dResult) {
- Long oid = (Long)resultElement[0];
- contractor = (Contractor)resultElement[1];
- assertTrue(contractor.getOID() == oid);
- assertEquals(dept.getOID(), contractor.getDept().getOID());
- }
-
- qS = "SELECT c, c.OID FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- List<Object[]> eResult = q.getResultList();
- for (Object[] resultElement : eResult) {
- Long oid = (Long)resultElement[1];
- contractor = (Contractor)resultElement[0];
- assertTrue(contractor.getOID() == oid);
- assertEquals(dept.getOID(), contractor.getDept().getOID());
- }
-
- qS = "SELECT c.OID, c FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
- q = em.createQuery(qS);
- List<Object[]> fResult = q.getResultList();
- for (Object[] resultElement : fResult) {
- Long oid = (Long)resultElement[0];
- Contractor c = (Contractor)resultElement[1];
- assertTrue(oid.longValue() == c.getOID());
- assertEquals(dept.getOID(), c.getDept().getOID());
- }
-
- qS = "SELECT d,c FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT' " +
- " and c = ?1";
- q = em.createQuery(qS);
- q.setParameter(1, contractor);
- for (Object[] aResult: (List <Object[]>) q.getResultList()) {
- System.out.println(((Department)aResult[0]).getOID() + ", " + ((Contractor)aResult[1]).getOID());
- assertTrue(contractor.equals(aResult[1]));
- }
-
- qS = "SELECT c,d FROM Contractor c, Department d where d.OID = c.dept.OID and d.description = 'IT' " +
- " and c = ?1";
- q = em.createQuery(qS);
- q.setParameter(1, contractor);
- for (Object[] aResult: (List <Object[]>) q.getResultList()) {
- System.out.println(((Contractor)aResult[0]).getOID() + ", " + ((Department)aResult[1]).getOID());
- assertTrue(contractor.equals(aResult[0]));
- }
-
- qS = "SELECT p FROM Person p ";
- q = em.createQuery(qS);
- for (Object aResult: (List<Object>) q.getResultList()) {
- assertTrue(aResult instanceof Contractor);
- }
-
- em.close();
- }
-}
-
+/*
+ * 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.inheritance.jointable;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+
+public class TestInheritanceTypeJoinedQuery extends SQLListenerTestCase {
+
+ public void setUp() {
+ setUp(Contractor.class, Employee.class, Department.class, Person.class,
+ CLEAR_TABLES);
+ populate();
+ }
+
+ public void populate() {
+ EntityManager em = emf.createEntityManager();
+
+ Department d = new Department("IT");
+ for (int i = 0; i < 3; i++) {
+ Contractor c = new Contractor("ctr" + i);
+ c.setDept(d);
+ em.persist(c);
+ }
+ em.persist(d);
+
+ em.getTransaction().begin();
+ em.getTransaction().commit();
+ em.close();
+ }
+
+ public void testInheritanceTypeJoinedQuery() {
+ EntityManager em = emf.createEntityManager();
+ Query q = null;
+ String qS = null;
+ Department dept = null;
+
+ qS = "SELECT c.OID, c.dept FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ List<Object[]> lResult = q.getResultList();
+ for (Object[] resultElement : lResult) {
+ Long oid = (Long)resultElement[0];
+ dept = (Department)resultElement[1];
+ }
+
+ qS = "SELECT c.OID FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ for (Object resultElement : q.getResultList()) {
+ Long oid = (Long)resultElement;
+ }
+
+ qS = "SELECT d FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ for (Department aResult: (List <Department>) q.getResultList()) {
+ assertEquals(dept.getOID(), aResult.getOID());
+ }
+
+ qS = "SELECT c FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ for (Contractor aResult: (List <Contractor>) q.getResultList()) {
+ //System.out.println(aResult.getDescription() + ", " + aResult.getOID());
+ assertEquals(dept.getOID(), aResult.getDept().getOID());
+ }
+ qS = "SELECT c FROM Contractor c, Department d where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ for (Contractor aResult: (List <Contractor>) q.getResultList()) {
+ assertEquals(dept.getOID(), aResult.getDept().getOID());
+ }
+
+ qS = "SELECT c, c.OID FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ List<Object[]> cResult = q.getResultList();
+ Contractor contractor = null;
+ for (Object[] resultElement : cResult) {
+ contractor = (Contractor)resultElement[0];
+ Long oid = (Long)resultElement[1];
+ assertTrue(contractor.getOID() == oid);
+ assertEquals(dept.getOID(), contractor.getDept().getOID());
+ }
+
+ qS = "SELECT c.OID, c FROM Contractor c, Department d where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ List<Object[]> dResult = q.getResultList();
+ for (Object[] resultElement : dResult) {
+ Long oid = (Long)resultElement[0];
+ contractor = (Contractor)resultElement[1];
+ assertTrue(contractor.getOID() == oid);
+ assertEquals(dept.getOID(), contractor.getDept().getOID());
+ }
+
+ qS = "SELECT c, c.OID FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ List<Object[]> eResult = q.getResultList();
+ for (Object[] resultElement : eResult) {
+ Long oid = (Long)resultElement[1];
+ contractor = (Contractor)resultElement[0];
+ assertTrue(contractor.getOID() == oid);
+ assertEquals(dept.getOID(), contractor.getDept().getOID());
+ }
+
+ qS = "SELECT c.OID, c FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT'";
+ q = em.createQuery(qS);
+ List<Object[]> fResult = q.getResultList();
+ for (Object[] resultElement : fResult) {
+ Long oid = (Long)resultElement[0];
+ Contractor c = (Contractor)resultElement[1];
+ assertTrue(oid.longValue() == c.getOID());
+ assertEquals(dept.getOID(), c.getDept().getOID());
+ }
+
+ qS = "SELECT d,c FROM Department d, Contractor c where d.OID = c.dept.OID and d.description = 'IT' " +
+ " and c = ?1";
+ q = em.createQuery(qS);
+ q.setParameter(1, contractor);
+ for (Object[] aResult: (List <Object[]>) q.getResultList()) {
+ System.out.println(((Department)aResult[0]).getOID() + ", " + ((Contractor)aResult[1]).getOID());
+ assertTrue(contractor.equals(aResult[1]));
+ }
+
+ qS = "SELECT c,d FROM Contractor c, Department d where d.OID = c.dept.OID and d.description = 'IT' " +
+ " and c = ?1";
+ q = em.createQuery(qS);
+ q.setParameter(1, contractor);
+ for (Object[] aResult: (List <Object[]>) q.getResultList()) {
+ System.out.println(((Contractor)aResult[0]).getOID() + ", " + ((Department)aResult[1]).getOID());
+ assertTrue(contractor.equals(aResult[0]));
+ }
+
+ qS = "SELECT p FROM Person p ";
+ q = em.createQuery(qS);
+ for (Object aResult: (List<Object>) q.getResultList()) {
+ assertTrue(aResult instanceof Contractor);
+ }
+
+ em.close();
+ }
+}
+
Propchange: openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/inheritance/jointable/TestInheritanceTypeJoinedQuery.java
------------------------------------------------------------------------------
svn:eol-style = native