Author: epbernard
Date: 2007-01-17 20:43:00 -0500 (Wed, 17 Jan 2007)
New Revision: 11058
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/Order.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/OrderLine.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/OrderLinePk.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/Product.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/CompositeIdTest.java
Log:
ANN-492 tests
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/CompositeIdTest.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/CompositeIdTest.java 2007-01-17
23:26:34 UTC (rev 11057)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/CompositeIdTest.java 2007-01-18
01:43:00 UTC (rev 11058)
@@ -8,6 +8,10 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.cid.OrderLine;
+import org.hibernate.test.annotations.cid.Order;
+import org.hibernate.test.annotations.cid.Product;
+import org.hibernate.test.annotations.cid.OrderLinePk;
/**
* test some composite id functionalities
@@ -93,13 +97,43 @@
s.close();
}
+ public void testManyToOneInCompositeIdClass() throws Exception {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+ Order order = new Order();
+ s.persist( order );
+ Product product = new Product();
+ product.name = "small car";
+ s.persist( product );
+ OrderLinePk pk = new OrderLinePk();
+ OrderLine orderLine = new OrderLine();
+ orderLine.order = order;
+ orderLine.product = product;
+ s.persist(orderLine);
+ s.flush();
+ s.clear();
+
+ orderLine = (OrderLine) s.createQuery( "select ol from OrderLine ol"
).uniqueResult();
+ assertNotNull( orderLine.order );
+ assertEquals( order.id, orderLine.order.id );
+ assertNotNull( orderLine.product );
+ assertEquals( product.name, orderLine.product.name );
+
+ tx.rollback();
+ s.close();
+ }
+
protected Class[] getMappings() {
return new Class[]{
Parent.class,
Child.class,
Channel.class,
TvMagazin.class,
- Presenter.class
- };
+ Presenter.class,
+ Order.class,
+ Product.class,
+ OrderLine.class,
+ OrderLinePk.class
+ };
}
}
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/Order.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/Order.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/Order.java 2007-01-18
01:43:00 UTC (rev 11058)
@@ -0,0 +1,17 @@
+package org.hibernate.test.annotations.cid;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Table(name = "OrderTableFoobar")
+public class Order {
+ @Id
+ @GeneratedValue
+ public Integer id;
+}
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/OrderLine.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/OrderLine.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/OrderLine.java 2007-01-18
01:43:00 UTC (rev 11058)
@@ -0,0 +1,17 @@
+package org.hibernate.test.annotations.cid;
+
+import javax.persistence.Entity;
+import javax.persistence.IdClass;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+(a)IdClass(OrderLinePk.class)
+public class OrderLine {
+ @Id
+ public Order order;
+ @Id
+ public Product product;
+}
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/OrderLinePk.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/OrderLinePk.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/OrderLinePk.java 2007-01-18
01:43:00 UTC (rev 11058)
@@ -0,0 +1,18 @@
+package org.hibernate.test.annotations.cid;
+
+
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+import java.io.Serializable;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class OrderLinePk implements Serializable {
+ @ManyToOne
+ @JoinColumn(name = "foo", nullable = false)
+ public Order order;
+ @ManyToOne
+ @JoinColumn(name = "bar", nullable = false)
+ public Product product;
+}
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/Product.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/Product.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/cid/Product.java 2007-01-18
01:43:00 UTC (rev 11058)
@@ -0,0 +1,13 @@
+package org.hibernate.test.annotations.cid;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Product {
+ @Id
+ public String name;
+}