Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Commits List »

[hibernate-commits] Hibernate SVN: r14956 -
 annotations/trunk/src/test/org/hibernate/test/annotations/array.

hibernate-commits

2008-07-18


Author LoginPost Reply
Author: hardy.ferentschik
Date: 2008-07-18 08:08:43 -0400 (Fri, 18 Jul 2008)
New Revision: 14956

Modified:
 annotations/trunk/src/test/org/hibernate/test/annotations/array/ArrayTest.java
 annotations/trunk/src/test/org/hibernate/test/annotations/array/Contest.java
Log:
Added a @CollectionOfElements for enum array.

Modified: annotations/trunk/src/test/org/hibernate/test/annotations/array/ArrayTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/array/ArrayTest.java  2008-07-18 09:48:56 UTC (rev 14955)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/array/ArrayTest.java  2008-07-18 12:08:43 UTC (rev 14956)
@@(protected) @@
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.test.annotations.TestCase;
+import org.hibernate.test.annotations.array.Contest.Month;

/**
* @author Emmanuel Bernard
@@(protected) @@
   c2.setName( "Ferrari" );
   Contest contest = new Contest();
   contest.setResults( new Competitor[]{c1, c2} );
+    contest.setHeldIn(new Month[]{Month.January, Month.December});
   s.persist( contest );
   tx.commit();
   s.close();
@@(protected) @@
   assertNotNull( contest.getResults() );
   assertEquals( 2, contest.getResults().length );
   assertEquals( c2.getName(), contest.getResults()[1].getName() );
+    assertEquals( 2, contest.getHeldIn().length );
+    assertEquals( Month.January, contest.getHeldIn()[0] );
   tx.commit();
   s.close();
 }
@@(protected) @@
   super( x );
 }

+  @SuppressWarnings("unchecked")
 protected Class[] getMappings() {
   return new Class[]{
       Competitor.class,

Modified: annotations/trunk/src/test/org/hibernate/test/annotations/array/Contest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/array/Contest.java  2008-07-18 09:48:56 UTC (rev 14955)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/array/Contest.java  2008-07-18 12:08:43 UTC (rev 14956)
@@(protected) @@
import javax.persistence.Id;
import javax.persistence.OneToMany;

+import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;

/**
@@(protected) @@
public class Contest {
 private int id;
 private Competitor[] results;
+  private Month[] heldIn;

 @Id
 @GeneratedValue
@@(protected) @@
 public void setResults(Competitor[] results) {
   this.results = results;
 }
+  
+  @CollectionOfElements
+  @IndexColumn(name = "pos", base=1)
+  public Month[] getHeldIn() {
+    return heldIn;
+  }
+
+  public void setHeldIn(Month[] heldIn) {
+    this.heldIn = heldIn;
+  }
+  
+  public enum Month {
+    January, February, March, April, May, June, July, August, September, October, November, December;
+  };
}

_______________________________________________
hibernate-commits mailing list
hibernate-commits@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-commits
©2008 gg3721.com - Jax Systems, LLC, U.S.A.