Author: epbernard
Date: 2010-05-25 09:07:42 -0400 (Tue, 25 May 2010)
New Revision: 19600
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java
Modified:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java
Log:
HHH-5258 add tests on isLoaded and superclasses and private properties
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java
(from rev 19599,
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java 2010-05-25
13:07:42 UTC (rev 19600)
@@ -0,0 +1,24 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity @Table(name="tbl_Author")
+public class Author {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java
===================================================================
---
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java 2010-05-25
13:06:51 UTC (rev 19599)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java 2010-05-25
13:07:42 UTC (rev 19600)
@@ -8,10 +8,18 @@
* @author Emmanuel Bernard
*/
@Entity
-public class Book {
+public class Book extends CopyrightableContent {
private Long id;
private String name;
+ public Book() {
+ super();
+ }
+
+ public Book(Author a) {
+ super(a);
+ }
+
@Id
@GeneratedValue
public Long getId() {
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java
===================================================================
---
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java 2010-05-25
13:07:42 UTC (rev 19600)
@@ -0,0 +1,31 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToOne;
+import javax.persistence.MappedSuperclass;
+
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+public abstract class CopyrightableContent {
+ private Author author;
+
+ public CopyrightableContent() {
+ }
+
+ public CopyrightableContent(Author author) {
+ this.author = author;
+ }
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Author getAuthor() {
+ return author;
+ }
+
+ private void setAuthor(Author author) {
+ this.author = author;
+ }
+}
Modified:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java
===================================================================
---
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java 2010-05-25
13:06:51 UTC (rev 19599)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java 2010-05-25
13:07:42 UTC (rev 19600)
@@ -56,7 +56,8 @@
return new Class[] {
Book.class,
Umbrella.class,
- Sickness.class
+ Sickness.class,
+ Author.class
};
}
}
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java
(rev 0)
+++
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java 2010-05-25
13:07:42 UTC (rev 19600)
@@ -0,0 +1,36 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.test.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class IsLoadedTest extends TestCase {
+
+ public void testIsLoadedOnPrivateSuperclassProperty() {
+ EntityManager em = factory.createEntityManager();
+ em.getTransaction().begin();
+ Author a = new Author();
+ Book book = new Book(a);
+ em.persist( a );
+ em.persist( book );
+ em.flush();
+ em.clear();
+ book = em.find( Book.class, book.getId() );
+ assertTrue( em.getEntityManagerFactory().getPersistenceUnitUtil().isLoaded( book ) );
+ assertFalse( em.getEntityManagerFactory().getPersistenceUnitUtil().isLoaded( book,
"author" ) );
+ em.getTransaction().rollback();
+ em.close();
+ }
+
+ @Override
+ protected Class<?>[] getAnnotatedClasses() {
+ return new Class<?>[] {
+ Author.class,
+ Book.class,
+ CopyrightableContent.class
+ };
+ }
+}
Show replies by date