Author: dwoods
Date: Fri May 15 19:32:16 2009
New Revision: 775296
URL: http://svn.apache.org/viewvc?rev=775296&view=rev
Log:
OPENJPA-247 Add testcase showing new-delete-new-find issue has been fixed.
Patch from: BJ Reed
Added:
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/Place.java
(with props)
Modified:
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestPersistence.java
Added:
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/Place.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/Place.java?rev=775296&view=auto
==============================================================================
---
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/Place.java
(added)
+++
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/Place.java
Fri May 15 19:32:16 2009
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.simple;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+...@entity
+public class Place {
+ private String location;
+
+ @Id
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+}
+
Propchange:
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/Place.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestPersistence.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestPersistence.java?rev=775296&r1=775295&r2=775296&view=diff
==============================================================================
---
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestPersistence.java
(original)
+++
openjpa/branches/1.3.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/simple/TestPersistence.java
Fri May 15 19:32:16 2009
@@ -34,7 +34,7 @@
extends SingleEMFTestCase {
public void setUp() {
- setUp(AllFieldTypes.class);
+ setUp(AllFieldTypes.class, Place.class);
}
public void testCreateEntityManager() {
@@ -87,6 +87,45 @@
em.close();
}
+ public void testNewDeleteNew() {
+ EntityManager em = emf.createEntityManager();
+
+ // create new
+ Place place = new Place();
+ place.setLocation("Lexington");
+ assertFalse(em.contains(place));
+ em.getTransaction().begin();
+ em.persist(place);
+ em.getTransaction().commit();
+ assertTrue(em.contains(place));
+
+ // find and verify
+ place = em.find(Place.class, "Lexington");
+ assertNotNull(place);
+ assertEquals("Lexington", place.getLocation());
+
+ // delete
+ em.getTransaction().begin();
+ em.remove(place);
+ em.getTransaction().commit();
+ assertFalse(em.contains(place));
+
+ // recreate
+ place = new Place();
+ place.setLocation("Lexington");
+ assertFalse(em.contains(place));
+ em.getTransaction().begin();
+ em.persist(place);
+ em.getTransaction().commit();
+ assertTrue(em.contains(place));
+
+ // find and verify
+ place = em.find(Place.class, "Lexington");
+ assertNotNull(place);
+ assertEquals("Lexington", place.getLocation());
+ em.close();
+ }
+
public static void main(String[] args) {
TestRunner.run(TestPersistence.class);
}