Author: epbernard
Date: 2008-03-03 22:52:43 -0500 (Mon, 03 Mar 2008)
New Revision: 14386
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/A.java
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/B.java
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/BId.java
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/C.java
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/CId.java
Log:
ANN-676 tests
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/A.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/A.java
(rev 0)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/A.java 2008-03-04
03:52:43 UTC (rev 14386)
@@ -0,0 +1,39 @@
+//$
+package org.hibernate.test.annotations.idmanytoone.alphabetical;
+
+import java.util.List;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+@Entity
+public class A {
+
+ @Id
+ private int id;
+
+ @OneToMany( mappedBy = "parent" )
+ List<C> children;
+
+ public A() {
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public List<C> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<C> children) {
+ this.children = children;
+ }
+
+
+}
+
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java
(rev 0)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/AlphabeticalIdManyToOneTest.java 2008-03-04
03:52:43 UTC (rev 14386)
@@ -0,0 +1,24 @@
+//$
+package org.hibernate.test.annotations.idmanytoone.alphabetical;
+
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class AlphabeticalIdManyToOneTest extends TestCase {
+ public void testAlphabeticalTest() throws Exception {
+ //test through deployment
+ }
+
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ B.class,
+ C.class,
+ A.class
+
+
+ };
+ }
+}
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/B.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/B.java
(rev 0)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/B.java 2008-03-04
03:52:43 UTC (rev 14386)
@@ -0,0 +1,39 @@
+//$
+package org.hibernate.test.annotations.idmanytoone.alphabetical;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+
+@Entity
+@IdClass( BId.class )
+public class B {
+
+ @Id
+ private C parent;
+
+ @Id
+ private int sequenceNumber;
+
+ public B() {
+ }
+
+ public C getParent() {
+ return parent;
+ }
+
+ public void setParent(C parent) {
+ this.parent = parent;
+ }
+
+ public int getSequenceNumber() {
+ return sequenceNumber;
+ }
+
+ public void setSequenceNumber(int sequenceNumber) {
+ this.sequenceNumber = sequenceNumber;
+ }
+
+
+}
+
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/BId.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/BId.java
(rev 0)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/BId.java 2008-03-04
03:52:43 UTC (rev 14386)
@@ -0,0 +1,69 @@
+//$
+package org.hibernate.test.annotations.idmanytoone.alphabetical;
+
+import java.io.Serializable;
+import javax.persistence.Embeddable;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+
+@Embeddable
+public class BId implements Serializable {
+
+ @ManyToOne
+ @JoinColumns( {
+ @JoinColumn( name = "aId", nullable = false ),
+ @JoinColumn( name = "bSequenceNumber", nullable = false )
+ } )
+ private C parent;
+
+ private int sequenceNumber;
+
+ public BId() {
+ }
+
+ public C getParent() {
+ return parent;
+ }
+
+ public void setParent(C parent) {
+ this.parent = parent;
+ }
+
+ public int getSequenceNumber() {
+ return sequenceNumber;
+ }
+
+ public void setSequenceNumber(int sequenceNumber) {
+ this.sequenceNumber = sequenceNumber;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( parent == null ) ? 0 : parent.hashCode() );
+ result = prime * result + sequenceNumber;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ final BId other = (BId) obj;
+ if ( parent == null ) {
+ if ( other.parent != null )
+ return false;
+ }
+ else if ( !parent.equals( other.parent ) )
+ return false;
+ if ( sequenceNumber != other.sequenceNumber )
+ return false;
+ return true;
+ }
+}
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/C.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/C.java
(rev 0)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/C.java 2008-03-04
03:52:43 UTC (rev 14386)
@@ -0,0 +1,52 @@
+//$
+package org.hibernate.test.annotations.idmanytoone.alphabetical;
+
+import java.util.List;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.OneToMany;
+
+@Entity
+@IdClass( CId.class )
+public class C {
+
+ @Id
+ private A parent;
+
+ @Id
+ private int sequenceNumber;
+
+ @OneToMany( mappedBy = "parent" )
+ List<B> children;
+
+ public C() {
+ }
+
+ public A getParent() {
+ return parent;
+ }
+
+ public void setParent(A parent) {
+ this.parent = parent;
+ }
+
+ public int getSequenceNumber() {
+ return sequenceNumber;
+ }
+
+ public void setSequenceNumber(int sequenceNumber) {
+ this.sequenceNumber = sequenceNumber;
+ }
+
+ public List<B> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<B> children) {
+ this.children = children;
+ }
+
+
+}
+
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/CId.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/CId.java
(rev 0)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/idmanytoone/alphabetical/CId.java 2008-03-04
03:52:43 UTC (rev 14386)
@@ -0,0 +1,67 @@
+//$
+package org.hibernate.test.annotations.idmanytoone.alphabetical;
+
+import java.io.Serializable;
+import javax.persistence.Embeddable;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+
+@Embeddable
+public class CId implements Serializable {
+
+ @ManyToOne
+ @JoinColumn( name = "aId", nullable = false )
+ private A parent;
+
+ private int sequenceNumber;
+
+ public CId() {
+ }
+
+ public A getParent() {
+ return parent;
+ }
+
+ public void setParent(A parent) {
+ this.parent = parent;
+ }
+
+ public int getSequenceNumber() {
+ return sequenceNumber;
+ }
+
+ public void setSequenceNumber(int sequenceNumber) {
+ this.sequenceNumber = sequenceNumber;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( parent == null ) ? 0 : parent.hashCode() );
+ result = prime * result + sequenceNumber;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ final CId other = (CId) obj;
+ if ( parent == null ) {
+ if ( other.parent != null )
+ return false;
+ }
+ else if ( !parent.equals( other.parent ) )
+ return false;
+ if ( sequenceNumber != other.sequenceNumber )
+ return false;
+ return true;
+ }
+
+
+}