Skip to content

Commit f7c1a05

Browse files
committed
HHH-19324 - Switch tests using hbm.xml to use mapping.xml
1 parent 7e9bf7e commit f7c1a05

File tree

23 files changed

+338
-288
lines changed

23 files changed

+338
-288
lines changed

hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-7.0.xsd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3302,7 +3302,10 @@
33023302
</xsd:choice>
33033303
<xsd:choice>
33043304
<xsd:sequence>
3305-
<xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
3305+
<xsd:choice minOccurs="0">
3306+
<xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
3307+
<xsd:element name="map-key-formula" type="xsd:string" minOccurs="0"/>
3308+
</xsd:choice>
33063309
<xsd:element name="map-key-type" type="orm:user-type" minOccurs="0"/>
33073310
</xsd:sequence>
33083311
<xsd:sequence>

hibernate-core/src/test/java/org/hibernate/orm/test/collection/list/IterateOverListInTheSetMethodTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,16 @@
1919

2020
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
2121

22+
@SuppressWarnings("JUnitMalformedDeclaration")
2223
@DomainModel(
23-
xmlMappings = "org/hibernate/orm/test/collection/list/ParentChildMapping.hbm.xml"
24+
xmlMappings = "org/hibernate/orm/test/collection/list/ParentChildMapping.xml"
2425
)
2526
@SessionFactory
2627
public class IterateOverListInTheSetMethodTest {
2728

2829
@AfterEach
2930
public void tearDown(SessionFactoryScope scope) {
30-
scope.inTransaction(
31-
session -> {
32-
session.createMutationQuery( "delete from Child" ).executeUpdate();
33-
session.createMutationQuery( "delete from Parent" ).executeUpdate();
34-
}
35-
);
31+
scope.dropData();
3632
}
3733

3834

hibernate-core/src/test/java/org/hibernate/orm/test/collection/list/PersistentListTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
*
3333
* @author Steve Ebersole
3434
*/
35-
@DomainModel(
36-
xmlMappings = "org/hibernate/orm/test/collection/list/Mappings.hbm.xml"
37-
)
35+
@SuppressWarnings("JUnitMalformedDeclaration")
36+
@DomainModel(xmlMappings = "org/hibernate/orm/test/collection/list/Mappings.xml")
3837
@SessionFactory
3938
public class PersistentListTest {
4039

@@ -131,9 +130,9 @@ public void testInverseListIndex2(SessionFactoryScope scope) {
131130
connection -> {
132131
SimpleSelect select = new SimpleSelect( sessionFactory )
133132
.setTableName( collectionPersister.getTableName() )
134-
.addColumn( "order_id" )
135-
.addColumn( "INDX" )
136-
.addColumn( "PRD_CODE" );
133+
.addColumn( "order_fk" )
134+
.addColumn( "list_index" )
135+
.addColumn( "prod_code" );
137136
final String sql = select.toStatementString();
138137
PreparedStatement preparedStatement = ( (SessionImplementor) session2 ).getJdbcCoordinator()
139138
.getStatementPreparer()

hibernate-core/src/test/java/org/hibernate/orm/test/collection/map/Parent.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public class Parent {
1515
private String name;
16-
private Map children = new HashMap();
16+
private Map<String,Child> children = new HashMap<>();
1717

1818
public Parent() {
1919
}
@@ -30,11 +30,11 @@ public void setName(String name) {
3030
this.name = name;
3131
}
3232

33-
public Map getChildren() {
33+
public Map<String,Child> getChildren() {
3434
return children;
3535
}
3636

37-
public void setChildren(Map children) {
37+
public void setChildren(Map<String,Child> children) {
3838
this.children = children;
3939
}
4040

hibernate-core/src/test/java/org/hibernate/orm/test/collection/map/PersistentMapTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* @author Gail Badner
4444
*/
4545
@DomainModel(
46-
xmlMappings = "org/hibernate/orm/test/collection/map/Mappings.hbm.xml",
46+
xmlMappings = "org/hibernate/orm/test/collection/map/Mappings.xml",
4747
annotatedClasses = {
4848
PersistentMapTest.User.class,
4949
PersistentMapTest.UserData.class,

hibernate-core/src/test/java/org/hibernate/orm/test/collection/original/CollectionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
/**
2929
* @author Gavin King
3030
*/
31+
@SuppressWarnings("JUnitMalformedDeclaration")
3132
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsNoColumnInsert.class)
3233
@DomainModel(xmlMappings = {
3334
"org/hibernate/orm/test/collection/original/UserPermissions.hbm.xml",
34-
"org/hibernate/orm/test/collection/original/Zoo.hbm.xml",
35+
"org/hibernate/orm/test/collection/original/Zoo.xml",
3536
})
3637
@SessionFactory
3738
public class CollectionTest {

hibernate-core/src/test/java/org/hibernate/orm/test/collection/original/Zoo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
public class Zoo {
1010
long id;
11-
List animals = new ArrayList();
11+
List<Animal> animals = new ArrayList<>();
1212

1313
public long getId() {
1414
return id;
1515
}
1616
public void setId( long id ) {
1717
this.id = id;
1818
}
19-
public List getAnimals() {
19+
public List<Animal> getAnimals() {
2020
return animals;
2121
}
22-
public void setAnimals(List animals) {
22+
public void setAnimals(List<Animal> animals) {
2323
this.animals = animals;
2424
}
2525

hibernate-core/src/test/java/org/hibernate/orm/test/collection/set/Parent.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public class Parent {
1515
private String name;
16-
private Set children = new HashSet();
16+
private Set<Child> children = new HashSet<>();
1717

1818
public Parent() {
1919
}
@@ -30,11 +30,11 @@ public void setName(String name) {
3030
this.name = name;
3131
}
3232

33-
public Set getChildren() {
33+
public Set<Child> getChildren() {
3434
return children;
3535
}
3636

37-
public void setChildren(Set children) {
37+
public void setChildren(Set<Child> children) {
3838
this.children = children;
3939
}
4040
}

hibernate-core/src/test/java/org/hibernate/orm/test/collection/set/PersistentSetNonLazyTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@
1010
*/
1111

1212
import org.hibernate.testing.orm.junit.DomainModel;
13+
import org.hibernate.testing.orm.junit.FailureExpected;
14+
import org.hibernate.testing.orm.junit.JiraKey;
1315
import org.hibernate.testing.orm.junit.SessionFactory;
1416
import org.hibernate.testing.orm.junit.SessionFactoryScope;
1517
import org.junit.jupiter.api.Test;
1618

19+
@SuppressWarnings("JUnitMalformedDeclaration")
1720
@DomainModel(
18-
xmlMappings = "org/hibernate/orm/test/collection/set/Mappings.hbm.xml",
21+
xmlMappings = "org/hibernate/orm/test/collection/set/MappingsNonLazy.xml",
1922
concurrencyStrategy = "nonstrict-read-write"
2023
)
2124
@SessionFactory(generateStatistics = true)
2225
public class PersistentSetNonLazyTest extends PersistentSetTest {
2326

2427
@Test
25-
// @FailureExpected(
26-
// jiraKey = "HHH-3799",
27-
// reason = "known to fail with non-lazy collection using query cache"
28-
// )
28+
@JiraKey("HHH-3799")
29+
@FailureExpected(reason = "known to fail with non-lazy collection using query cache")
2930
public void testLoadChildCheckParentContainsChildCache(SessionFactoryScope scope) {
3031
super.testLoadChildCheckParentContainsChildCache( scope );
3132
}

hibernate-core/src/test/java/org/hibernate/orm/test/collection/set/PersistentSetTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,17 @@
3131
/**
3232
* @author Steve Ebersole
3333
*/
34-
@DomainModel(
35-
xmlMappings = "org/hibernate/orm/test/collection/set/Mappings.hbm.xml"
36-
)
34+
@SuppressWarnings("JUnitMalformedDeclaration")
35+
@DomainModel(xmlMappings = "org/hibernate/orm/test/collection/set/Mappings.xml")
3736
@SessionFactory(generateStatistics = true)
38-
@ServiceRegistry(
39-
settings = {
40-
@Setting(
41-
name = AvailableSettings.USE_SECOND_LEVEL_CACHE, value = "true"
42-
),
43-
@Setting(
44-
name = AvailableSettings.USE_QUERY_CACHE, value = "true"
45-
)
46-
}
47-
)
37+
@ServiceRegistry(settings = {
38+
@Setting(
39+
name = AvailableSettings.USE_SECOND_LEVEL_CACHE, value = "true"
40+
),
41+
@Setting(
42+
name = AvailableSettings.USE_QUERY_CACHE, value = "true"
43+
)
44+
})
4845
public class PersistentSetTest {
4946

5047
@Test

0 commit comments

Comments
 (0)