openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r681746 - in /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity: Book.java Page.java TestMultipleLevelDerivedIdentity.java
Date Fri, 01 Aug 2008 16:55:23 GMT
Author: ppoddar
Date: Fri Aug  1 09:55:22 2008
New Revision: 681746

URL: http://svn.apache.org/viewvc?rev=681746&view=rev
Log:
OPENJPA-207: Add new test case for multi-level derived id

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Book.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Page.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMultipleLevelDerivedIdentity.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Book.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Book.java?rev=681746&r1=681745&r2=681746&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Book.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Book.java
Fri Aug  1 09:55:22 2008
@@ -55,7 +55,7 @@
     
     @Id
     @Column(nullable = false)
-    @ManyToOne (cascade = CascadeType.ALL)
+    @ManyToOne
     private Library library;
     
     private String author;

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Page.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Page.java?rev=681746&r1=681745&r2=681746&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Page.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/Page.java
Fri Aug  1 09:55:22 2008
@@ -51,7 +51,7 @@
 
     @Id
     @Column(nullable = false)
-    @ManyToOne (cascade = CascadeType.ALL)
+    @ManyToOne
     @JoinColumns({
         @JoinColumn(name="BOOK_LIBRARY_LIBRARY_NAME", referencedColumnName="LIBRARY_LIBRARY_NAME"),
         @JoinColumn(name="BOOK_BOOK_NAME", referencedColumnName="BOOK_NAME")    

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMultipleLevelDerivedIdentity.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMultipleLevelDerivedIdentity.java?rev=681746&r1=681745&r2=681746&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMultipleLevelDerivedIdentity.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/enhance/identity/TestMultipleLevelDerivedIdentity.java
Fri Aug  1 09:55:22 2008
@@ -25,19 +25,20 @@
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
- * Tests entities that use compound keys that includes entity relationship at
+ * Tests entities with compound keys that include entity relationship at
  * more than one level.
  * 
- * Page has a compound identity to Book which itself uses a compound identity to
- * Library.
+ * Page has a compound identity to Book which in turn uses a compound identity 
+ * to Library.
  * 
- * Test case and domain classes were originally part of the reported issue <A
- * href="https://issues.apache.org/jira/browse/OPENJPA-207">OPENJPA-207</A>
+ * Test case and domain classes were originally part of the reported issue 
+ * <A href="https://issues.apache.org/jira/browse/OPENJPA-207">OPENJPA-207</A>
  * 
  * @author Jeffrey Blattman
  * @author Pinaki Poddar
  * 
  */
+@SuppressWarnings("unchecked")
 public class TestMultipleLevelDerivedIdentity extends SingleEMFTestCase {
 	private static String LIBRARY_NAME = "LIB";
 	private static String BOOK_NAME    = "foo";
@@ -49,10 +50,6 @@
 		create();
 	}
 	
-//	public void tearDown() throws Exception {
-//		
-//	}
-	
 	public void testPersist() {
 		create();
 	}
@@ -82,7 +79,6 @@
 			assertEquals(page, page.getBook().getPage(page.getNumber()));
 		}
 	}
-
 	
 	public void testQueryLeafLevel() {
 		EntityManager em = emf.createEntityManager();
@@ -141,7 +137,7 @@
 		em.getTransaction().commit();
 	}
 	
-	public void testDelete() {
+	public void testDeleteRoot() {
 		EntityManager em = emf.createEntityManager();
 		em.getTransaction().begin();
 		Library lib = em.find(Library.class, LIBRARY_NAME);
@@ -152,6 +148,39 @@
 	    assertEquals(0, count(Book.class));
 	    assertEquals(0, count(Page.class));
 	}
+	
+	public void testDeleteLeafObtainedByQuery() {
+		EntityManager em = emf.createEntityManager();
+		em.getTransaction().begin();
+		Page page = (Page)em.createQuery("SELECT p FROM Page p WHERE p.number=2")
+			.getSingleResult();
+		assertNotNull(page);
+		em.remove(page);
+		em.getTransaction().commit();
+		
+	    assertEquals(1, count(Library.class));
+	    assertEquals(1, count(Book.class));
+	    assertEquals(NUM_PAGES-1, count(Page.class));
+	}
+	
+	public void testDeleteLeafObtainedByFind() {
+		EntityManager em = emf.createEntityManager();
+		em.getTransaction().begin();
+		BookId bookId = new BookId();
+		bookId.setLibrary(LIBRARY_NAME);
+		bookId.setName(BOOK_NAME);
+		PageId pageId = new PageId();
+		pageId.setBook(bookId);
+		pageId.setNumber(2);
+		Page page = em.find(Page.class, pageId);
+		assertNotNull(page);
+		em.remove(page);
+		em.getTransaction().commit();
+		
+	    assertEquals(1, count(Library.class));
+	    assertEquals(1, count(Book.class));
+	    assertEquals(NUM_PAGES-1, count(Page.class));
+	}
 
 	
 	/**



Mime
View raw message