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

hibernate-core/src/test/resources/org/hibernate/orm/test/collection/lazynocascade/Parent.xml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,3 @@
4343
</entity-mappings>
4444

4545

46-
47-
48-
<!--<!DOCTYPE hibernate-mapping PUBLIC-->
49-
<!-- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"-->
50-
<!-- "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">-->
51-
<!--<hibernate-mapping package="org.hibernate.orm.test.collection.lazynocascade">-->
52-
<!-- <class name="Parent">-->
53-
<!-- <id name="id" column="parent_id">-->
54-
<!-- <generator class="increment"/>-->
55-
<!-- </id>-->
56-
<!-- <set name="children" cascade="all">-->
57-
<!-- <key column="parent_id"/>-->
58-
<!-- <one-to-many class="BaseChild"/>-->
59-
<!-- </set>-->
60-
<!-- </class>-->
61-
62-
<!-- <class name="BaseChild" >-->
63-
<!-- <id name="id" column="base_child_id">-->
64-
<!-- <generator class="increment"/>-->
65-
<!-- </id>-->
66-
<!-- <discriminator/>-->
67-
<!-- <many-to-one name="dependency" column="dependency_id" class="BaseChild" lazy="proxy"/>-->
68-
<!-- <subclass name="Child">-->
69-
<!-- <property name="name" column="name" type="string"/>-->
70-
<!-- </subclass>-->
71-
<!-- </class>-->
72-
<!--</hibernate-mapping>-->

hibernate-core/src/test/resources/org/hibernate/orm/test/collection/list/Mappings.hbm.xml

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
~ SPDX-License-Identifier: Apache-2.0
4+
~ Copyright Red Hat Inc. and Hibernate Authors
5+
-->
6+
<entity-mappings xmlns="http://www.hibernate.org/xsd/orm/mapping"
7+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
8+
version="7.0">
9+
<package>org.hibernate.orm.test.collection.list</package>
10+
11+
<entity class="ListOwner">
12+
<attributes>
13+
<id name="name"/>
14+
<many-to-one name="parent">
15+
<join-column name="parent_fk"/>
16+
</many-to-one>
17+
<one-to-many name="children" mapped-by="parent" target-entity="ListOwner">
18+
<order-column name="list_index"/>
19+
<cascade>
20+
<cascade-all/>
21+
</cascade>
22+
</one-to-many>
23+
</attributes>
24+
</entity>
25+
26+
<entity class="Order">
27+
<table name="orders"/>
28+
<attributes>
29+
<id name="id">
30+
<generated-value generator="increment"/>
31+
</id>
32+
<basic name="code"/>
33+
<one-to-many name="lineItems" mapped-by="order">
34+
<order-column name="list_index"/>
35+
<cascade>
36+
<cascade-all/>
37+
</cascade>
38+
</one-to-many>
39+
</attributes>
40+
</entity>
41+
42+
<entity class="LineItem">
43+
<table name="line_items"/>
44+
<attributes>
45+
<id name="id">
46+
<generated-value generator="increment"/>
47+
</id>
48+
<basic name="productCode">
49+
<column name="prod_code"/>
50+
</basic>
51+
<basic name="quantity">
52+
<column name="qty"/>
53+
</basic>
54+
<many-to-one name="order">
55+
<join-column name="order_fk"/>
56+
<cascade>
57+
<cascade-all/>
58+
</cascade>
59+
</many-to-one>
60+
</attributes>
61+
</entity>
62+
</entity-mappings>
63+

hibernate-core/src/test/resources/org/hibernate/orm/test/collection/list/ParentChildMapping.hbm.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)