From 413ca60475e9f859b0070e8e875129650970dee7 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 10 Jan 2013 14:42:12 -0800 Subject: [PATCH] HHH-7917 : Add support for ordered sets --- .../internal/HibernateTypeHelper.java | 4 +++- .../collectionelement/OrderByTest.java | 4 ---- .../collectionelement/Products.java | 1 + .../annotations/collectionelement/Widgets.java | 18 ++---------------- .../hibernate/test/ordered/OrderByTest.java | 1 - 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/HibernateTypeHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/HibernateTypeHelper.java index bf409d257c..5ef5cdfbc1 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/HibernateTypeHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/HibernateTypeHelper.java @@ -475,7 +475,9 @@ class HibernateTypeHelper { pluralAttributeBinding.getComparator() ); } - // TODO: else if ( pluralAttributeBinding.hasOrder() ) { orderedSet... } + else if ( pluralAttributeBinding.getOrderBy() != null ) { + return typeFactory().orderedSet( role, propertyRef ); + } else { return typeFactory().set( role, propertyRef ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/OrderByTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/OrderByTest.java index 09d4092011..e7e3cf096e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/OrderByTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/OrderByTest.java @@ -34,7 +34,6 @@ import org.hibernate.Transaction; import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; -@FailureExpectedWithNewMetamodel public class OrderByTest extends BaseCoreFunctionalTestCase { @Test public void testOrderByName() throws Exception { @@ -47,17 +46,14 @@ public class OrderByTest extends BaseCoreFunctionalTestCase { Widgets widget = new Widgets(); widget.setName("hammer"); set.add(widget); - s.persist(widget); widget = new Widgets(); widget.setName("axel"); set.add(widget); - s.persist(widget); widget = new Widgets(); widget.setName("screwdriver"); set.add(widget); - s.persist(widget); p.setWidgets(set); s.persist(p); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Products.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Products.java index 0ed2eb347f..c5eb132285 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Products.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Products.java @@ -4,6 +4,7 @@ import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.OneToMany; import javax.persistence.OrderBy; @SuppressWarnings({"unchecked", "serial"}) diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Widgets.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Widgets.java index b888a85bbb..5c5cc73d97 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Widgets.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Widgets.java @@ -1,12 +1,9 @@ package org.hibernate.test.annotations.collectionelement; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; +import javax.persistence.Embeddable; -@Entity +@Embeddable public class Widgets { private String name; - private int id; public Widgets() { @@ -19,15 +16,4 @@ public class Widgets { public void setName(String name) { this.name = name; } - - @Id - @GeneratedValue - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - } diff --git a/hibernate-core/src/test/java/org/hibernate/test/ordered/OrderByTest.java b/hibernate-core/src/test/java/org/hibernate/test/ordered/OrderByTest.java index 1e7fd734c7..33578191bb 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/ordered/OrderByTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/ordered/OrderByTest.java @@ -49,7 +49,6 @@ public class OrderByTest extends BaseCoreFunctionalTestCase { @Test @SuppressWarnings( {"unchecked"}) - @FailureExpectedWithNewMetamodel public void testOrderBy() { Search s = new Search("Hibernate"); s.getSearchResults().add("jboss.com");