Skip to content

Commit 377f087

Browse files
committed
fix crazy-lookin' SQL in SubselectTest
I'm actually amazed this worked on so many databases
1 parent cec73b0 commit 377f087

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/subselect/HighestBid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*/
1616
@Entity
17-
@Subselect("select Item.name as name, max(Bid.amount) as amount from Item, Bid where Bid.itemId = Item.id group by Item.name")
17+
@Subselect("select i.name as name, max(b.amount) as amount from Item i, Bid b where b.itemId = i.id group by i.name")
1818
@Synchronize({"Item", "Bid"})
1919
public class HighestBid {
2020

hibernate-core/src/test/java/org/hibernate/orm/test/annotations/subselect/SubselectTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.junit.Assert;
88
import org.junit.Test;
99

10-
import org.hibernate.query.Query;
1110
import org.hibernate.Session;
1211
import org.hibernate.Transaction;
1312
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@@ -45,15 +44,13 @@ public void testSubselectWithSynchronize() {
4544
s.persist(bid2);
4645

4746
//Because we use 'synchronize' annotation, this query should trigger session flush
48-
Query query = s.createQuery("from HighestBid b where b.name = :name");
47+
var query = s.createQuery("from HighestBid b where b.name = :name", HighestBid.class);
4948
query.setParameter( "name", "widget", StandardBasicTypes.STRING );
50-
HighestBid highestBid = (HighestBid) query.list().iterator().next();
49+
HighestBid highestBid = query.list().iterator().next();
5150

5251
Assert.assertEquals( 200.0, highestBid.getAmount(), 0.01 );
5352
tx.rollback();
5453
s.close();
55-
56-
5754
}
5855

5956
@Override

0 commit comments

Comments
 (0)