Author: epbernard
Date: 2007-03-23 21:02:24 -0400 (Fri, 23 Mar 2007)
New Revision: 11343
Added:
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/Branch.java
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/Leaf.java
Modified:
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/FetchingTest.java
Log:
test
Added:
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/Branch.java
===================================================================
---
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/Branch.java
(rev 0)
+++
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/Branch.java 2007-03-24
01:02:24 UTC (rev 11343)
@@ -0,0 +1,40 @@
+//$Id: $
+package org.hibernate.test.annotations.fetch;
+
+import java.util.Set;
+import java.util.HashSet;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.OneToMany;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Branch {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ @OneToMany(mappedBy = "branch", fetch = FetchType.EAGER )
+ private Set<Leaf> leaves = new HashSet<Leaf>();
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Set<Leaf> getLeaves() {
+ return leaves;
+ }
+
+ public void setLeaves(Set<Leaf> leaves) {
+ this.leaves = leaves;
+ }
+}
Modified:
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/FetchingTest.java
===================================================================
---
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/FetchingTest.java 2007-03-23
19:13:47 UTC (rev 11342)
+++
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/FetchingTest.java 2007-03-24
01:02:24 UTC (rev 11343)
@@ -91,6 +91,25 @@
s.close();
}
+ public void testOneToManyFetchEager() throws Exception {
+ Branch b = new Branch();
+ Session s = openSession( );
+ s.getTransaction().begin();
+ s.persist( b );
+ s.flush();
+ Leaf l = new Leaf();
+ l.setBranch( b );
+ s.persist( l );
+ s.flush();
+
+ s.clear();
+
+ s.createCriteria( Branch.class ).list();
+
+ s.getTransaction().rollback();
+ s.close();
+ }
+
public FetchingTest(String x) {
super( x );
}
@@ -98,7 +117,9 @@
protected Class[] getMappings() {
return new Class[]{
Person.class,
- Stay.class
+ Stay.class,
+ Branch.class,
+ Leaf.class
};
}
}
Added:
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/Leaf.java
===================================================================
---
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/Leaf.java
(rev 0)
+++
trunk/HibernateExt/annotations/src/test/org/hibernate/test/annotations/fetch/Leaf.java 2007-03-24
01:02:24 UTC (rev 11343)
@@ -0,0 +1,37 @@
+//$Id: $
+package org.hibernate.test.annotations.fetch;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Leaf {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ @ManyToOne
+ private Branch branch;
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Branch getBranch() {
+ return branch;
+ }
+
+ public void setBranch(Branch branch) {
+ this.branch = branch;
+ }
+}
Show replies by date