You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by jr...@apache.org on 2012/04/26 21:53:51 UTC
svn commit: r1331051 [4/5] - in /openjpa/trunk:
openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/
openjpa-kernel/src/main/java/org/apache/openjpa/util/
openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/
openjpa-...
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Department.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Department.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Department.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Department.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,135 @@
+/*
+ * 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.proxy.delayed.llist;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Queue;
+
+import javax.persistence.CascadeType;
+import javax.persistence.CollectionTable;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinTable;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderColumn;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.Award;
+import org.apache.openjpa.persistence.proxy.delayed.Certification;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.persistence.proxy.delayed.Location;
+import org.apache.openjpa.persistence.proxy.delayed.Product;
+
+@Entity
+@Table(name="DC_DEPARTMENT")
+public class Department implements IDepartment, Serializable {
+
+ private static final long serialVersionUID = -6923551949033215888L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY, targetEntity=Employee.class)
+ @JoinTable(name="DC_DEP_EMP")
+ private Queue<IEmployee> employees;
+
+ @OrderColumn
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
+ @JoinTable(name="DC_DEP_LOC")
+ private LinkedList<Location> locations;
+
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
+ @JoinTable(name="DC_DEP_PRD")
+ private Queue<Product> products;
+
+ @ElementCollection(fetch=FetchType.LAZY)
+ @CollectionTable(name="DC_DEP_CERT")
+ private Queue<Certification> certifications;
+
+ @ElementCollection(fetch=FetchType.EAGER)
+ @CollectionTable(name="DC_DEP_AWD")
+ private LinkedList<Award> awards;
+
+ @Override
+ public void setEmployees(Collection<IEmployee> employees) {
+ this.employees = (Queue<IEmployee>)employees;
+ }
+
+ @Override
+ public Collection<IEmployee> getEmployees() {
+ return employees;
+ }
+
+ @Override
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public void setLocations(Collection<Location> locations) {
+ this.locations =(LinkedList<Location>)locations;
+ }
+
+ @Override
+ public Collection<Location> getLocations() {
+ return locations;
+ }
+
+ @Override
+ public void setProducts(Collection<Product> products) {
+ this.products = (Queue<Product>)products;
+ }
+
+ @Override
+ public Collection<Product> getProducts() {
+ return products;
+ }
+
+ @Override
+ public void setCertifications(Collection<Certification> certifications) {
+ this.certifications = (Queue<Certification>)certifications;
+ }
+
+ @Override
+ public Collection<Certification> getCertifications() {
+ return certifications;
+ }
+
+ @Override
+ public void setAwards(Collection<Award> awards) {
+ this.awards = (LinkedList<Award>)awards;
+ }
+
+ @Override
+ public Collection<Award> getAwards() {
+ return awards;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Department.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Employee.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Employee.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Employee.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Employee.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,89 @@
+/*
+ * 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.proxy.delayed.llist;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+
+@Entity
+@Table(name="DC_EMPLOYEE")
+public class Employee implements IEmployee, Serializable {
+
+ private static final long serialVersionUID = 1878272252981151246L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private String empName;
+
+ @ManyToOne(targetEntity=Department.class)
+ @JoinColumn(name="DEPT_ID")
+ private IDepartment dept;
+
+ public void setEmpName(String empName) {
+ this.empName = empName;
+ }
+
+ public String getEmpName() {
+ return empName;
+ }
+
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+
+ public void setDept(IDepartment dept) {
+ this.dept = dept;
+ }
+
+
+ public IDepartment getDept() {
+ return dept;
+ }
+
+ @Override
+ public int hashCode() {
+ return getId();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Employee) {
+ Employee e = (Employee)obj;
+ return e.getId() == getId() && e.getEmpName().equals(getEmpName());
+ }
+ return false;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Employee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Member.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Member.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Member.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Member.java Thu Apr 26 19:53:49 2012
@@ -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.proxy.delayed.llist;
+
+import java.util.Collection;
+import java.util.Queue;
+
+import javax.persistence.Embeddable;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+
+@Embeddable
+public class Member implements IMember {
+
+ private String name;
+
+ @OneToMany(fetch=FetchType.LAZY, mappedBy="userIdent", targetEntity=Account.class)
+ private Queue<IAccount> accounts;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setAccounts(Collection<IAccount> accounts) {
+ this.accounts = (Queue<IAccount>)accounts;
+ }
+
+ public Collection<IAccount> getAccounts() {
+ return accounts;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/Member.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxy.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxy.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxy.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,138 @@
+/*
+ * 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.proxy.delayed.llist;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.proxy.delayed.Award;
+import org.apache.openjpa.persistence.proxy.delayed.Certification;
+import org.apache.openjpa.persistence.proxy.delayed.DelayedProxyCollectionsTestCase;
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+import org.apache.openjpa.persistence.proxy.delayed.Location;
+import org.apache.openjpa.persistence.proxy.delayed.Product;
+
+public class TestDelayedLinkedListProxy extends DelayedProxyCollectionsTestCase {
+
+ public static Object[] _pcList = {
+ Employee.class,
+ Department.class,
+ UserIdentity.class,
+ Member.class,
+ Account.class
+ };
+
+ public void setUp() {
+ super.setUp(_pcList);
+ }
+
+ public void setUp(Object... props){
+ List<Object> parms = new ArrayList<Object>();
+ // Add package-specific types
+ parms.addAll(Arrays.asList(_pcList));
+ // Add properties from super
+ parms.addAll(Arrays.asList(props));
+ super.setUp(parms.toArray());
+ }
+
+ public IUserIdentity findUserIdentity(EntityManager em, int id) {
+ return em.find(UserIdentity.class, id);
+ }
+
+ public IDepartment findDepartment(EntityManager em, int id) {
+ return em.find(Department.class, id);
+ }
+
+ public IUserIdentity createUserIdentity() {
+ UserIdentity ui = new UserIdentity();
+ return ui;
+ }
+
+ public IAccount createAccount(String name, IUserIdentity ui) {
+ IAccount acct = new Account(name, ui);
+ return acct;
+ }
+
+ public IDepartment createDepartment() {
+ Department d = new Department();
+ return d;
+ }
+
+ public IMember createMember(String name) {
+ Member m = new Member();
+ m.setName(name);
+ return m;
+ }
+
+ @Override
+ public IEmployee createEmployee() {
+ Employee e = new Employee();
+ return e;
+ }
+
+ @Override
+ public Collection<IEmployee> createEmployees() {
+ return new LinkedList<IEmployee>();
+ }
+
+ @Override
+ public Collection<Product> createProducts() {
+ return new LinkedList<Product>();
+ }
+
+ @Override
+ public Collection<Award> createAwards() {
+ return new LinkedList<Award>();
+ }
+
+ @Override
+ public Collection<Location> createLocations() {
+ return new LinkedList<Location>();
+ }
+
+ @Override
+ public Collection<Certification> createCertifications() {
+ return new LinkedList<Certification>();
+ }
+
+ @Override
+ public Collection<IAccount> createAccounts() {
+ return new LinkedList<IAccount>();
+ }
+
+ @Override
+ public IEmployee getEmployee(Collection<IEmployee> emps, int idx) {
+ return ((LinkedList<IEmployee>)emps).get(idx);
+ }
+
+ @Override
+ public Product getProduct(Collection<Product> products, int idx) {
+ return ((LinkedList<Product>)products).get(idx);
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxyDetachLite.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxyDetachLite.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxyDetachLite.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxyDetachLite.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,88 @@
+/*
+ * 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.proxy.delayed.llist;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.util.DelayedLinkedListProxy;
+
+public class TestDelayedLinkedListProxyDetachLite extends TestDelayedLinkedListProxy {
+
+ @Override
+ public void setUp() {
+ super.setUp(
+ "openjpa.DetachState", "loaded(LiteAutoDetach=true,detachProxyFields=false)");
+ }
+
+ /*
+ * Verify that a collection can be loaded post detachment
+ */
+ @Override
+ public void testPostDetach() {
+ EntityManager em = emf.createEntityManager();
+
+ // Create a new department and an employee
+ IDepartment d = createDepartment();
+ IEmployee e = createEmployee();
+ e.setDept(d);
+ e.setEmpName("John");
+ Collection<IEmployee> emps = createEmployees();
+ emps.add(e);
+ d.setEmployees(emps);
+
+ em.getTransaction().begin();
+ em.persist(d);
+ em.getTransaction().commit();
+ resetSQL();
+ em.clear();
+
+ d = findDepartment(em, d.getId());
+ emps = d.getEmployees();
+ em.close();
+
+ // assert there was no select on the employee table
+ assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ assertTrue(emps instanceof DelayedLinkedListProxy);
+ DelayedLinkedListProxy dep = (DelayedLinkedListProxy)emps;
+ dep.setDirectAccess(true);
+ assertEquals(0, dep.size());
+ dep.setDirectAccess(false);
+ assertNotNull(emps);
+ // call contains and assert a select from the employee table
+ // occurred that the expected entities are returned.
+ resetSQL();
+ assertTrue(emps.contains(e));
+ e = getEmployee(emps,0);
+ assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ resetSQL();
+ assertEquals(1, emps.size());
+ // Verify the delay load entity is detached
+ assertTrue(e instanceof PersistenceCapable);
+ PersistenceCapable pc = (PersistenceCapable)e;
+ // LiteAutoDetach
+ assertTrue(pc.pcGetStateManager() == null);
+ // verify a second SQL was not issued to get the size
+ assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/TestDelayedLinkedListProxyDetachLite.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/UserIdentity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/UserIdentity.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/UserIdentity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/UserIdentity.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,58 @@
+/*
+ * 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.proxy.delayed.llist;
+
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+
+@Entity
+@Table(name="DC_UIDENT")
+public class UserIdentity implements IUserIdentity {
+
+ @Id
+ @GeneratedValue
+ @Column(name="UID_ID")
+ private int id;
+
+ @Embedded
+ private Member member;
+
+ public void setMember(IMember member) {
+ this.member = (Member)member;
+ }
+
+ public IMember getMember() {
+ return member;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/llist/UserIdentity.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Account.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Account.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Account.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Account.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,85 @@
+/*
+ * 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.proxy.delayed.pqueue;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+
+@Entity
+@Table(name="DC_ACCOUNT")
+public class Account implements IAccount, Comparable<Account> {
+
+ public Account() {
+ }
+
+ public Account(String name, IUserIdentity uid) {
+ setName(name);
+ setUserIdent(uid);
+ }
+
+ @Id
+ @GeneratedValue
+ @Column(name="ACCT_ID")
+ private int id;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(name="UID_ID")
+ private UserIdentity userIdent;
+
+ private String name;
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setUserIdent(IUserIdentity userIdent) {
+ this.userIdent = (UserIdentity)userIdent;
+ }
+
+ public IUserIdentity getUserIdent() {
+ return userIdent;
+ }
+
+ @Override
+ public int compareTo(Account o) {
+ return new Integer(getId()).compareTo(o.getId());
+ }
+
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Account.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Department.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Department.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Department.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Department.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,134 @@
+/*
+ * 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.proxy.delayed.pqueue;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.PriorityQueue;
+
+import javax.persistence.CascadeType;
+import javax.persistence.CollectionTable;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinTable;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderColumn;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.Award;
+import org.apache.openjpa.persistence.proxy.delayed.Certification;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.persistence.proxy.delayed.Location;
+import org.apache.openjpa.persistence.proxy.delayed.Product;
+
+@Entity
+@Table(name="DC_DEPARTMENT")
+public class Department implements IDepartment, Serializable {
+
+ private static final long serialVersionUID = -6923551949033215888L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY, targetEntity=Employee.class)
+ @JoinTable(name="DC_DEP_EMP")
+ private PriorityQueue<IEmployee> employees;
+
+ @OrderColumn
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
+ @JoinTable(name="DC_DEP_LOC")
+ private PriorityQueue<Location> locations;
+
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
+ @JoinTable(name="DC_DEP_PRD")
+ private PriorityQueue<Product> products;
+
+ @ElementCollection(fetch=FetchType.LAZY)
+ @CollectionTable(name="DC_DEP_CERT")
+ private PriorityQueue<Certification> certifications;
+
+ @ElementCollection(fetch=FetchType.EAGER)
+ @CollectionTable(name="DC_DEP_AWD")
+ private PriorityQueue<Award> awards;
+
+ @Override
+ public void setEmployees(Collection<IEmployee> employees) {
+ this.employees = (PriorityQueue<IEmployee>)employees;
+ }
+
+ @Override
+ public Collection<IEmployee> getEmployees() {
+ return employees;
+ }
+
+ @Override
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public void setLocations(Collection<Location> locations) {
+ this.locations =(PriorityQueue<Location>)locations;
+ }
+
+ @Override
+ public Collection<Location> getLocations() {
+ return locations;
+ }
+
+ @Override
+ public void setProducts(Collection<Product> products) {
+ this.products = (PriorityQueue<Product>)products;
+ }
+
+ @Override
+ public Collection<Product> getProducts() {
+ return products;
+ }
+
+ @Override
+ public void setCertifications(Collection<Certification> certifications) {
+ this.certifications = (PriorityQueue<Certification>)certifications;
+ }
+
+ @Override
+ public Collection<Certification> getCertifications() {
+ return certifications;
+ }
+
+ @Override
+ public void setAwards(Collection<Award> awards) {
+ this.awards = (PriorityQueue<Award>)awards;
+ }
+
+ @Override
+ public Collection<Award> getAwards() {
+ return awards;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Department.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Employee.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Employee.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Employee.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Employee.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,96 @@
+/*
+ * 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.proxy.delayed.pqueue;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+
+@Entity
+@Table(name="DC_EMPLOYEE")
+public class Employee implements IEmployee, Serializable, Comparable<Employee> {
+
+ private static final long serialVersionUID = 1878272252981151246L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private String empName;
+
+ @ManyToOne(targetEntity=Department.class)
+ @JoinColumn(name="DEPT_ID")
+ private IDepartment dept;
+
+ public void setEmpName(String empName) {
+ this.empName = empName;
+ }
+
+ public String getEmpName() {
+ return empName;
+ }
+
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+
+ public void setDept(IDepartment dept) {
+ this.dept = dept;
+ }
+
+
+ public IDepartment getDept() {
+ return dept;
+ }
+
+ @Override
+ public int hashCode() {
+ return getId();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Employee) {
+ Employee e = (Employee)obj;
+ return e.getId() == getId() && e.getEmpName().equals(getEmpName());
+ }
+ return false;
+ }
+
+ @Override
+ public int compareTo(Employee e) {
+ String nameId = getEmpName() + getId();
+ String nameId2 = e.getEmpName() + e.getId();
+ return nameId.compareTo(nameId2);
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Employee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Member.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Member.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Member.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Member.java Thu Apr 26 19:53:49 2012
@@ -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.proxy.delayed.pqueue;
+
+import java.util.Collection;
+import java.util.Set;
+
+import javax.persistence.Embeddable;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+
+@Embeddable
+public class Member implements IMember {
+
+ private String name;
+
+ @OneToMany(fetch=FetchType.LAZY, mappedBy="userIdent", targetEntity=Account.class)
+ private Set<IAccount> accounts;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setAccounts(Collection<IAccount> accounts) {
+ this.accounts = (Set<IAccount>)accounts;
+ }
+
+ public Collection<IAccount> getAccounts() {
+ return accounts;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/Member.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxy.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxy.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxy.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,143 @@
+/*
+ * 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.proxy.delayed.pqueue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.PriorityQueue;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.proxy.delayed.Award;
+import org.apache.openjpa.persistence.proxy.delayed.Certification;
+import org.apache.openjpa.persistence.proxy.delayed.DelayedProxyCollectionsTestCase;
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+import org.apache.openjpa.persistence.proxy.delayed.Location;
+import org.apache.openjpa.persistence.proxy.delayed.Product;
+
+public class TestDelayedPriorityQueueProxy extends DelayedProxyCollectionsTestCase {
+
+ public static Object[] _pcList = {
+ Employee.class,
+ Department.class,
+ UserIdentity.class,
+ Member.class,
+ Account.class
+ };
+
+ public void setUp() {
+ super.setUp(_pcList);
+ }
+
+ public void setUp(Object... props){
+ List<Object> parms = new ArrayList<Object>();
+ // Add package-specific types
+ parms.addAll(Arrays.asList(_pcList));
+ // Add properties from super
+ parms.addAll(Arrays.asList(props));
+ super.setUp(parms.toArray());
+ }
+
+ public IUserIdentity findUserIdentity(EntityManager em, int id) {
+ return em.find(UserIdentity.class, id);
+ }
+
+ public IDepartment findDepartment(EntityManager em, int id) {
+ return em.find(Department.class, id);
+ }
+
+ public IUserIdentity createUserIdentity() {
+ UserIdentity ui = new UserIdentity();
+ return ui;
+ }
+
+ public IAccount createAccount(String name, IUserIdentity ui) {
+ IAccount acct = new Account(name, ui);
+ return acct;
+ }
+
+ public IDepartment createDepartment() {
+ Department d = new Department();
+ return d;
+ }
+
+ public IMember createMember(String name) {
+ Member m = new Member();
+ m.setName(name);
+ return m;
+ }
+
+ @Override
+ public IEmployee createEmployee() {
+ Employee e = new Employee();
+ return e;
+ }
+
+ @Override
+ public Collection<IEmployee> createEmployees() {
+ return new PriorityQueue<IEmployee>();
+ }
+
+ @Override
+ public Collection<Product> createProducts() {
+ return new PriorityQueue<Product>();
+ }
+
+ @Override
+ public Collection<Award> createAwards() {
+ return new PriorityQueue<Award>();
+ }
+
+ @Override
+ public Collection<Location> createLocations() {
+ return new PriorityQueue<Location>();
+ }
+
+ @Override
+ public Collection<Certification> createCertifications() {
+ return new PriorityQueue<Certification>();
+ }
+
+ @Override
+ public Collection<IAccount> createAccounts() {
+ return new PriorityQueue<IAccount>();
+ }
+
+ @Override
+ public IEmployee getEmployee(Collection<IEmployee> emps, int idx) {
+ if (emps == null || emps.iterator() == null) {
+ return null;
+ }
+ return emps.iterator().next();
+ }
+
+ @Override
+ public Product getProduct(Collection<Product> products, int idx) {
+ if (products == null || products.iterator() == null) {
+ return null;
+ }
+ return products.iterator().next();
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxyDetachLite.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxyDetachLite.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxyDetachLite.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxyDetachLite.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,88 @@
+/*
+ * 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.proxy.delayed.pqueue;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.util.DelayedPriorityQueueProxy;
+
+public class TestDelayedPriorityQueueProxyDetachLite extends TestDelayedPriorityQueueProxy {
+
+ @Override
+ public void setUp() {
+ super.setUp(
+ "openjpa.DetachState", "loaded(LiteAutoDetach=true,detachProxyFields=false)");
+ }
+
+ /*
+ * Verify that a collection can be loaded post detachment
+ */
+ @Override
+ public void testPostDetach() {
+ EntityManager em = emf.createEntityManager();
+
+ // Create a new department and an employee
+ IDepartment d = createDepartment();
+ IEmployee e = createEmployee();
+ e.setDept(d);
+ e.setEmpName("John");
+ Collection<IEmployee> emps = createEmployees();
+ emps.add(e);
+ d.setEmployees(emps);
+
+ em.getTransaction().begin();
+ em.persist(d);
+ em.getTransaction().commit();
+ resetSQL();
+ em.clear();
+
+ d = findDepartment(em, d.getId());
+ emps = d.getEmployees();
+ em.close();
+
+ // assert there was no select on the employee table
+ assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ assertTrue(emps instanceof DelayedPriorityQueueProxy);
+ DelayedPriorityQueueProxy dep = (DelayedPriorityQueueProxy)emps;
+ dep.setDirectAccess(true);
+ assertEquals(0, dep.size());
+ dep.setDirectAccess(false);
+ assertNotNull(emps);
+ // call contains and assert a select from the employee table
+ // occurred that the expected entities are returned.
+ resetSQL();
+ assertTrue(emps.contains(e));
+ e = getEmployee(emps,0);
+ assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ resetSQL();
+ assertEquals(1, emps.size());
+ // Verify the delay load entity is detached
+ assertTrue(e instanceof PersistenceCapable);
+ PersistenceCapable pc = (PersistenceCapable)e;
+ // LiteAutoDetach
+ assertTrue(pc.pcGetStateManager() == null);
+ // verify a second SQL was not issued to get the size
+ assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/TestDelayedPriorityQueueProxyDetachLite.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/UserIdentity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/UserIdentity.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/UserIdentity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/UserIdentity.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,58 @@
+/*
+ * 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.proxy.delayed.pqueue;
+
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+
+@Entity
+@Table(name="DC_UIDENT")
+public class UserIdentity implements IUserIdentity {
+
+ @Id
+ @GeneratedValue
+ @Column(name="UID_ID")
+ private int id;
+
+ @Embedded
+ private Member member;
+
+ public void setMember(IMember member) {
+ this.member = (Member)member;
+ }
+
+ public IMember getMember() {
+ return member;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/pqueue/UserIdentity.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Account.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Account.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Account.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Account.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,84 @@
+/*
+ * 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.proxy.delayed.tset;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+
+@Entity
+@Table(name="DC_ACCOUNT")
+public class Account implements IAccount, Comparable<Account> {
+
+ public Account() {
+ }
+
+ public Account(String name, IUserIdentity uid) {
+ setName(name);
+ setUserIdent(uid);
+ }
+
+ @Id
+ @GeneratedValue
+ @Column(name="ACCT_ID")
+ private int id;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(name="UID_ID")
+ private UserIdentity userIdent;
+
+ private String name;
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setUserIdent(IUserIdentity userIdent) {
+ this.userIdent = (UserIdentity)userIdent;
+ }
+
+ public IUserIdentity getUserIdent() {
+ return userIdent;
+ }
+
+ @Override
+ public int compareTo(Account o) {
+ return new Integer(getId()).compareTo(o.getId());
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Account.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Department.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Department.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Department.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Department.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,135 @@
+/*
+ * 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.proxy.delayed.tset;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.persistence.CascadeType;
+import javax.persistence.CollectionTable;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinTable;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderColumn;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.Award;
+import org.apache.openjpa.persistence.proxy.delayed.Certification;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.persistence.proxy.delayed.Location;
+import org.apache.openjpa.persistence.proxy.delayed.Product;
+
+@Entity
+@Table(name="DC_DEPARTMENT")
+public class Department implements IDepartment, Serializable {
+
+ private static final long serialVersionUID = -6923551949033215888L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY, targetEntity=Employee.class)
+ @JoinTable(name="DC_DEP_EMP")
+ private TreeSet<IEmployee> employees;
+
+ @OrderColumn
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
+ @JoinTable(name="DC_DEP_LOC")
+ private TreeSet<Location> locations;
+
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
+ @JoinTable(name="DC_DEP_PRD")
+ private SortedSet<Product> products;
+
+ @ElementCollection(fetch=FetchType.LAZY)
+ @CollectionTable(name="DC_DEP_CERT")
+ private TreeSet<Certification> certifications;
+
+ @ElementCollection(fetch=FetchType.EAGER)
+ @CollectionTable(name="DC_DEP_AWD")
+ private SortedSet<Award> awards;
+
+ @Override
+ public void setEmployees(Collection<IEmployee> employees) {
+ this.employees = (TreeSet<IEmployee>)employees;
+ }
+
+ @Override
+ public Collection<IEmployee> getEmployees() {
+ return employees;
+ }
+
+ @Override
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public void setLocations(Collection<Location> locations) {
+ this.locations =(TreeSet<Location>)locations;
+ }
+
+ @Override
+ public Collection<Location> getLocations() {
+ return locations;
+ }
+
+ @Override
+ public void setProducts(Collection<Product> products) {
+ this.products = (TreeSet<Product>)products;
+ }
+
+ @Override
+ public Collection<Product> getProducts() {
+ return products;
+ }
+
+ @Override
+ public void setCertifications(Collection<Certification> certifications) {
+ this.certifications = (TreeSet<Certification>)certifications;
+ }
+
+ @Override
+ public Collection<Certification> getCertifications() {
+ return certifications;
+ }
+
+ @Override
+ public void setAwards(Collection<Award> awards) {
+ this.awards = (TreeSet<Award>)awards;
+ }
+
+ @Override
+ public Collection<Award> getAwards() {
+ return awards;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Department.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Employee.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Employee.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Employee.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Employee.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,96 @@
+/*
+ * 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.proxy.delayed.tset;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+
+@Entity
+@Table(name="DC_EMPLOYEE")
+public class Employee implements IEmployee, Serializable, Comparable<Employee> {
+
+ private static final long serialVersionUID = 1878272252981151246L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private String empName;
+
+ @ManyToOne(targetEntity=Department.class)
+ @JoinColumn(name="DEPT_ID")
+ private IDepartment dept;
+
+ public void setEmpName(String empName) {
+ this.empName = empName;
+ }
+
+ public String getEmpName() {
+ return empName;
+ }
+
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+
+ public void setDept(IDepartment dept) {
+ this.dept = dept;
+ }
+
+
+ public IDepartment getDept() {
+ return dept;
+ }
+
+ @Override
+ public int hashCode() {
+ return getId();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Employee) {
+ Employee e = (Employee)obj;
+ return e.getId() == getId() && e.getEmpName().equals(getEmpName());
+ }
+ return false;
+ }
+
+ @Override
+ public int compareTo(Employee e) {
+ String nameId = getEmpName() + getId();
+ String nameId2 = e.getEmpName() + e.getId();
+ return nameId.compareTo(nameId2);
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Employee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Member.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Member.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Member.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Member.java Thu Apr 26 19:53:49 2012
@@ -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.proxy.delayed.tset;
+
+import java.util.Collection;
+import java.util.PriorityQueue;
+
+import javax.persistence.Embeddable;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+
+@Embeddable
+public class Member implements IMember {
+
+ private String name;
+
+ @OneToMany(fetch=FetchType.LAZY, mappedBy="userIdent", targetEntity=Account.class)
+ private PriorityQueue<IAccount> accounts;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setAccounts(Collection<IAccount> accounts) {
+ this.accounts = (PriorityQueue<IAccount>)accounts;
+ }
+
+ public Collection<IAccount> getAccounts() {
+ return accounts;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/Member.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxy.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxy.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxy.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,143 @@
+/*
+ * 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.proxy.delayed.tset;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.TreeSet;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.persistence.proxy.delayed.Award;
+import org.apache.openjpa.persistence.proxy.delayed.Certification;
+import org.apache.openjpa.persistence.proxy.delayed.DelayedProxyCollectionsTestCase;
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+import org.apache.openjpa.persistence.proxy.delayed.Location;
+import org.apache.openjpa.persistence.proxy.delayed.Product;
+
+public class TestDelayedTreeSetProxy extends DelayedProxyCollectionsTestCase {
+
+ public static Object[] _pcList = {
+ Employee.class,
+ Department.class,
+ UserIdentity.class,
+ Member.class,
+ Account.class
+ };
+
+ public void setUp() {
+ super.setUp(_pcList);
+ }
+
+ public void setUp(Object... props){
+ List<Object> parms = new ArrayList<Object>();
+ // Add package-specific types
+ parms.addAll(Arrays.asList(_pcList));
+ // Add properties from super
+ parms.addAll(Arrays.asList(props));
+ super.setUp(parms.toArray());
+ }
+
+ public IUserIdentity findUserIdentity(EntityManager em, int id) {
+ return em.find(UserIdentity.class, id);
+ }
+
+ public IDepartment findDepartment(EntityManager em, int id) {
+ return em.find(Department.class, id);
+ }
+
+ public IUserIdentity createUserIdentity() {
+ UserIdentity ui = new UserIdentity();
+ return ui;
+ }
+
+ public IAccount createAccount(String name, IUserIdentity ui) {
+ IAccount acct = new Account(name, ui);
+ return acct;
+ }
+
+ public IDepartment createDepartment() {
+ Department d = new Department();
+ return d;
+ }
+
+ public IMember createMember(String name) {
+ Member m = new Member();
+ m.setName(name);
+ return m;
+ }
+
+ @Override
+ public IEmployee createEmployee() {
+ Employee e = new Employee();
+ return e;
+ }
+
+ @Override
+ public Collection<IEmployee> createEmployees() {
+ return new TreeSet<IEmployee>();
+ }
+
+ @Override
+ public Collection<Product> createProducts() {
+ return new TreeSet<Product>();
+ }
+
+ @Override
+ public Collection<Award> createAwards() {
+ return new TreeSet<Award>();
+ }
+
+ @Override
+ public Collection<Location> createLocations() {
+ return new TreeSet<Location>();
+ }
+
+ @Override
+ public Collection<Certification> createCertifications() {
+ return new TreeSet<Certification>();
+ }
+
+ @Override
+ public Collection<IAccount> createAccounts() {
+ return new TreeSet<IAccount>();
+ }
+
+ @Override
+ public IEmployee getEmployee(Collection<IEmployee> emps, int idx) {
+ if (emps == null || emps.iterator() == null) {
+ return null;
+ }
+ return emps.iterator().next();
+ }
+
+ @Override
+ public Product getProduct(Collection<Product> products, int idx) {
+ if (products == null || products.iterator() == null) {
+ return null;
+ }
+ return products.iterator().next();
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxyDetachLite.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxyDetachLite.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxyDetachLite.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxyDetachLite.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,88 @@
+/*
+ * 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.proxy.delayed.tset;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.util.DelayedTreeSetProxy;
+
+public class TestDelayedTreeSetProxyDetachLite extends TestDelayedTreeSetProxy {
+
+ @Override
+ public void setUp() {
+ super.setUp(
+ "openjpa.DetachState", "loaded(LiteAutoDetach=true,detachProxyFields=false)");
+ }
+
+ /*
+ * Verify that a collection can be loaded post detachment
+ */
+ @Override
+ public void testPostDetach() {
+ EntityManager em = emf.createEntityManager();
+
+ // Create a new department and an employee
+ IDepartment d = createDepartment();
+ IEmployee e = createEmployee();
+ e.setDept(d);
+ e.setEmpName("John");
+ Collection<IEmployee> emps = createEmployees();
+ emps.add(e);
+ d.setEmployees(emps);
+
+ em.getTransaction().begin();
+ em.persist(d);
+ em.getTransaction().commit();
+ resetSQL();
+ em.clear();
+
+ d = findDepartment(em, d.getId());
+ emps = d.getEmployees();
+ em.close();
+
+ // assert there was no select on the employee table
+ assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ assertTrue(emps instanceof DelayedTreeSetProxy);
+ DelayedTreeSetProxy dep = (DelayedTreeSetProxy)emps;
+ dep.setDirectAccess(true);
+ assertEquals(0, dep.size());
+ dep.setDirectAccess(false);
+ assertNotNull(emps);
+ // call contains and assert a select from the employee table
+ // occurred that the expected entities are returned.
+ resetSQL();
+ assertTrue(emps.contains(e));
+ e = getEmployee(emps,0);
+ assertAnySQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ resetSQL();
+ assertEquals(1, emps.size());
+ // Verify the delay load entity is detached
+ assertTrue(e instanceof PersistenceCapable);
+ PersistenceCapable pc = (PersistenceCapable)e;
+ // LiteAutoDetach
+ assertTrue(pc.pcGetStateManager() == null);
+ // verify a second SQL was not issued to get the size
+ assertNoneSQLAnyOrder("SELECT .* DC_EMPLOYEE .*");
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/TestDelayedTreeSetProxyDetachLite.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/UserIdentity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/UserIdentity.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/UserIdentity.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/UserIdentity.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,58 @@
+/*
+ * 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.proxy.delayed.tset;
+
+import javax.persistence.Column;
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IMember;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+
+@Entity
+@Table(name="DC_UIDENT")
+public class UserIdentity implements IUserIdentity {
+
+ @Id
+ @GeneratedValue
+ @Column(name="UID_ID")
+ private int id;
+
+ @Embedded
+ private Member member;
+
+ public void setMember(IMember member) {
+ this.member = (Member)member;
+ }
+
+ public IMember getMember() {
+ return member;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/tset/UserIdentity.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Account.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Account.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Account.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Account.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,79 @@
+/*
+ * 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.proxy.delayed.vec;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IAccount;
+import org.apache.openjpa.persistence.proxy.delayed.IUserIdentity;
+
+@Entity
+@Table(name="DC_ACCOUNT")
+public class Account implements IAccount {
+
+ public Account() {
+ }
+
+ public Account(String name, IUserIdentity uid) {
+ setName(name);
+ setUserIdent(uid);
+ }
+
+ @Id
+ @GeneratedValue
+ @Column(name="ACCT_ID")
+ private int id;
+
+ @ManyToOne(fetch=FetchType.LAZY)
+ @JoinColumn(name="UID_ID")
+ private UserIdentity userIdent;
+
+ private String name;
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setUserIdent(IUserIdentity userIdent) {
+ this.userIdent = (UserIdentity)userIdent;
+ }
+
+ public IUserIdentity getUserIdent() {
+ return userIdent;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Account.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Department.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Department.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Department.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Department.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,134 @@
+/*
+ * 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.proxy.delayed.vec;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Vector;
+
+import javax.persistence.CascadeType;
+import javax.persistence.CollectionTable;
+import javax.persistence.ElementCollection;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinTable;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderColumn;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.Award;
+import org.apache.openjpa.persistence.proxy.delayed.Certification;
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+import org.apache.openjpa.persistence.proxy.delayed.Location;
+import org.apache.openjpa.persistence.proxy.delayed.Product;
+
+@Entity
+@Table(name="DC_DEPARTMENT")
+public class Department implements IDepartment, Serializable {
+
+ private static final long serialVersionUID = -6923551949033215888L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY, targetEntity=Employee.class)
+ @JoinTable(name="DC_DEP_EMP")
+ private Vector<IEmployee> employees;
+
+ @OrderColumn
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY)
+ @JoinTable(name="DC_DEP_LOC")
+ private Vector<Location> locations;
+
+ @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
+ @JoinTable(name="DC_DEP_PRD")
+ private Vector<Product> products;
+
+ @ElementCollection(fetch=FetchType.LAZY)
+ @CollectionTable(name="DC_DEP_CERT")
+ private Vector<Certification> certifications;
+
+ @ElementCollection(fetch=FetchType.EAGER)
+ @CollectionTable(name="DC_DEP_AWD")
+ private Vector<Award> awards;
+
+ @Override
+ public void setEmployees(Collection<IEmployee> employees) {
+ this.employees = (Vector<IEmployee>)employees;
+ }
+
+ @Override
+ public Collection<IEmployee> getEmployees() {
+ return employees;
+ }
+
+ @Override
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public void setLocations(Collection<Location> locations) {
+ this.locations =(Vector<Location>)locations;
+ }
+
+ @Override
+ public Collection<Location> getLocations() {
+ return locations;
+ }
+
+ @Override
+ public void setProducts(Collection<Product> products) {
+ this.products = (Vector<Product>)products;
+ }
+
+ @Override
+ public Collection<Product> getProducts() {
+ return products;
+ }
+
+ @Override
+ public void setCertifications(Collection<Certification> certifications) {
+ this.certifications = (Vector<Certification>)certifications;
+ }
+
+ @Override
+ public Collection<Certification> getCertifications() {
+ return certifications;
+ }
+
+ @Override
+ public void setAwards(Collection<Award> awards) {
+ this.awards = (Vector<Award>)awards;
+ }
+
+ @Override
+ public Collection<Award> getAwards() {
+ return awards;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Department.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Employee.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Employee.java?rev=1331051&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Employee.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Employee.java Thu Apr 26 19:53:49 2012
@@ -0,0 +1,89 @@
+/*
+ * 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.proxy.delayed.vec;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.openjpa.persistence.proxy.delayed.IDepartment;
+import org.apache.openjpa.persistence.proxy.delayed.IEmployee;
+
+@Entity
+@Table(name="DC_EMPLOYEE")
+public class Employee implements IEmployee, Serializable {
+
+ private static final long serialVersionUID = 1878272252981151246L;
+
+ @Id
+ @GeneratedValue
+ private int id;
+
+ private String empName;
+
+ @ManyToOne(targetEntity=Department.class)
+ @JoinColumn(name="DEPT_ID")
+ private IDepartment dept;
+
+ public void setEmpName(String empName) {
+ this.empName = empName;
+ }
+
+ public String getEmpName() {
+ return empName;
+ }
+
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+
+ public void setDept(IDepartment dept) {
+ this.dept = dept;
+ }
+
+
+ public IDepartment getDept() {
+ return dept;
+ }
+
+ @Override
+ public int hashCode() {
+ return getId();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Employee) {
+ Employee e = (Employee)obj;
+ return e.getId() == getId() && e.getEmpName().equals(getEmpName());
+ }
+ return false;
+ }
+}
Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/delayed/vec/Employee.java
------------------------------------------------------------------------------
svn:eol-style = native