Author: epbernard
Date: 2007-01-17 17:16:33 -0500 (Wed, 17 Jan 2007)
New Revision: 11056
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/Item.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/ItemCost.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/Vendor.java
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/WarehouseItem.java
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/ReferencedColumnNameTest.java
Log:
ANN-509 more tests
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/Item.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/Item.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/Item.java 2007-01-17
22:16:33 UTC (rev 11056)
@@ -0,0 +1,23 @@
+//$Id: $
+package org.hibernate.test.annotations.referencedcolumnname;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Item {
+ int id;
+
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+}
\ No newline at end of file
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/ItemCost.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/ItemCost.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/ItemCost.java 2007-01-17
22:16:33 UTC (rev 11056)
@@ -0,0 +1,55 @@
+//$Id: $
+package org.hibernate.test.annotations.referencedcolumnname;
+
+import java.math.BigDecimal;
+import java.io.Serializable;
+import javax.persistence.Id;
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class ItemCost implements Serializable {
+ int id;
+ Item item;
+ Vendor vendor;
+ BigDecimal cost;
+
+
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @ManyToOne
+ public Item getItem() {
+ return item;
+ }
+
+ public void setItem(Item item) {
+ this.item = item;
+ }
+
+ @ManyToOne
+ public Vendor getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(Vendor vendor) {
+ this.vendor = vendor;
+ }
+
+ public BigDecimal getCost() {
+ return cost;
+ }
+
+ public void setCost(BigDecimal cost) {
+ this.cost = cost;
+ }
+}
Modified:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/ReferencedColumnNameTest.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/ReferencedColumnNameTest.java 2007-01-17
20:07:04 UTC (rev 11055)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/ReferencedColumnNameTest.java 2007-01-17
22:16:33 UTC (rev 11056)
@@ -2,6 +2,7 @@
package org.hibernate.test.annotations.referencedcolumnname;
import java.util.Iterator;
+import java.math.BigDecimal;
import org.hibernate.Session;
import org.hibernate.Transaction;
@@ -141,7 +142,36 @@
}
tx.commit();
s.close();
+ }
+ public void testManyToOneReferenceManyToOne() throws Exception {
+ Item item = new Item();
+ item.setId( 1 );
+ Vendor vendor = new Vendor();
+ vendor.setId( 1 );
+ ItemCost cost = new ItemCost();
+ cost.setCost( new BigDecimal(1) );
+ cost.setId( 1 );
+ cost.setItem( item );
+ cost.setVendor( vendor );
+ WarehouseItem wItem = new WarehouseItem();
+ wItem.setDefaultCost( cost );
+ wItem.setId( 1 );
+ wItem.setItem( item );
+ wItem.setQtyInStock( new BigDecimal(1) );
+ wItem.setVendor( vendor );
+ Session s = openSession( );
+ s.getTransaction().begin();
+ s.persist( item );
+ s.persist( vendor );
+ s.persist( cost );
+ s.persist( wItem );
+ s.flush();
+ s.clear();
+ wItem = (WarehouseItem) s.get(WarehouseItem.class, wItem.getId() );
+ assertNotNull( wItem.getDefaultCost().getItem() );
+ s.getTransaction().rollback();
+ s.close();
}
public ReferencedColumnNameTest(String x) {
@@ -156,7 +186,11 @@
Rambler.class,
Luggage.class,
Clothes.class,
- Inhabitant.class
+ Inhabitant.class,
+ Item.class,
+ ItemCost.class,
+ Vendor.class,
+ WarehouseItem.class
};
}
}
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/Vendor.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/Vendor.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/Vendor.java 2007-01-17
22:16:33 UTC (rev 11056)
@@ -0,0 +1,24 @@
+//$Id: $
+package org.hibernate.test.annotations.referencedcolumnname;
+
+import javax.persistence.Id;
+import javax.persistence.Entity;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class Vendor {
+ int id;
+
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+}
+
Added:
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/WarehouseItem.java
===================================================================
---
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/WarehouseItem.java
(rev 0)
+++
branches/Branch_3_2/HibernateExt/metadata/src/test/org/hibernate/test/annotations/referencedcolumnname/WarehouseItem.java 2007-01-17
22:16:33 UTC (rev 11056)
@@ -0,0 +1,71 @@
+//$Id: $
+package org.hibernate.test.annotations.referencedcolumnname;
+
+import java.math.BigDecimal;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.JoinColumn;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+public class WarehouseItem {
+
+ int id;
+ Item item;
+ Vendor vendor;
+ ItemCost defaultCost;
+ BigDecimal qtyInStock;
+
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public BigDecimal getQtyInStock() {
+ return qtyInStock;
+ }
+
+ public void setQtyInStock(BigDecimal qtyInStock) {
+ this.qtyInStock = qtyInStock;
+ }
+
+ @ManyToOne
+ public Item getItem() {
+ return item;
+ }
+
+ public void setItem(Item item) {
+ this.item = item;
+ }
+
+ @ManyToOne
+ public Vendor getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(Vendor vendor) {
+ this.vendor = vendor;
+ }
+
+ @ManyToOne
+ @JoinColumns({
+ @JoinColumn(name="vendor_id", referencedColumnName="vendor_id",
insertable=false, updatable=false),
+ @JoinColumn(name="item_id", referencedColumnName="item_id",
insertable=false, updatable=false)
+ })
+ public ItemCost getDefaultCost() {
+ return defaultCost;
+ }
+
+ public void setDefaultCost(ItemCost defaultCost) {
+ this.defaultCost = defaultCost;
+ }
+}
+
Show replies by date