Author: epbernard
Date: 2006-09-28 11:35:26 -0400 (Thu, 28 Sep 2006)
New Revision: 10533
Modified:
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Group.java
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
Log:
more tests
Modified:
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Group.java
===================================================================
---
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Group.java 2006-09-26
20:24:38 UTC (rev 10532)
+++
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/Group.java 2006-09-28
15:35:26 UTC (rev 10533)
@@ -10,6 +10,7 @@
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
+import javax.persistence.OrderBy;
/**
* @author Emmanuel Bernard
@@ -35,6 +36,7 @@
joinColumns = @JoinColumn(name = "group_id", referencedColumnName =
"id"),
inverseJoinColumns = @JoinColumn(name = "permission", referencedColumnName =
"permission")
)
+ @OrderBy("expirationDate")
public Collection<Permission> getPermissions() {
return permissions;
}
Modified:
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
===================================================================
---
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java 2006-09-26
20:24:38 UTC (rev 10532)
+++
trunk/HibernateExt/metadata/src/test/org/hibernate/test/annotations/manytomany/ManyToManyTest.java 2006-09-28
15:35:26 UTC (rev 10533)
@@ -439,6 +439,30 @@
}
}
+ public void testAssociationTableAndOrderBy() throws Exception {
+ Session s = openSession();
+ Permission readAccess = new Permission();
+ readAccess.setPermission( "read" );
+ readAccess.setExpirationDate( new Date() );
+ Permission writeAccess = new Permission();
+ writeAccess.setPermission( "write" );
+ writeAccess.setExpirationDate( new Date( new Date().getTime() - 10*60*1000 ) );
+ Collection<Permission> coll = new ArrayList<Permission>( 2 );
+ coll.add( readAccess );
+ coll.add( writeAccess );
+ Group group = new Group();
+ group.setId( new Integer( 1 ) );
+ group.setPermissions( coll );
+ s.getTransaction().begin();
+ s.persist( group );
+ s.flush();
+ s.clear();
+ group = (Group) s.get( Group.class, group.getId() );
+ assertEquals( "write",
group.getPermissions().iterator().next().getPermission() );
+ s.getTransaction().rollback();
+ s.close();
+ }
+
public void testJoinedSubclassManyToMany() throws Exception {
Session s = openSession();
Zone a = new Zone();