Skip to content

Commit aeaa65c

Browse files
committed
HHH-19676 add test
1 parent a4c7c89 commit aeaa65c

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ordering/OrderByFragmentTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static OrderByFragment translate(
5656

5757
public static void check(String fragment) {
5858
final var parseTree = buildParseTree( fragment );
59-
// TODO: check against the model
59+
// TODO: check against the model (requires the PluralAttributeMapping)
6060
}
6161

6262
private static OrderingParser.OrderByFragmentContext buildParseTree(String fragment) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.processor.test.orderedcollection;
6+
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.GeneratedValue;
9+
import jakarta.persistence.Id;
10+
import jakarta.persistence.Lob;
11+
12+
/**
13+
* @author Hardy Ferentschik
14+
*/
15+
@Entity
16+
public class PrintJob {
17+
@Id
18+
@GeneratedValue
19+
private long id;
20+
21+
@Lob
22+
private byte[] data;
23+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.processor.test.orderedcollection;
6+
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.GeneratedValue;
9+
import jakarta.persistence.Id;
10+
import jakarta.persistence.OneToMany;
11+
import jakarta.persistence.OrderBy;
12+
13+
import java.util.Set;
14+
15+
/**
16+
* @author Hardy Ferentschik
17+
*/
18+
@Entity
19+
public class Printer {
20+
@Id
21+
@GeneratedValue
22+
private long id;
23+
24+
@OneToMany
25+
@OrderBy("id desc, data")
26+
private Set<PrintJob> printQueue;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.processor.test.orderedcollection;
6+
7+
import org.hibernate.processor.test.util.CompilationTest;
8+
import org.hibernate.processor.test.util.WithClasses;
9+
import org.junit.jupiter.api.Test;
10+
11+
import static org.hibernate.processor.test.util.TestUtil.assertMetamodelClassGeneratedFor;
12+
import static org.hibernate.processor.test.util.TestUtil.assertPresenceOfFieldInMetamodelFor;
13+
14+
/**
15+
* @author Hardy Ferentschik
16+
*/
17+
@CompilationTest
18+
class SortedCollectionTest {
19+
20+
@Test
21+
@WithClasses({ Printer.class, PrintJob.class })
22+
void testGenerics() {
23+
assertMetamodelClassGeneratedFor( Printer.class );
24+
assertMetamodelClassGeneratedFor( PrintJob.class );
25+
assertPresenceOfFieldInMetamodelFor( Printer.class, "printQueue", "There sorted set attribute is missing" );
26+
}
27+
}

0 commit comments

Comments
 (0)