Skip to content

Commit fc8040f

Browse files
committed
HHH-19324 - Switch tests using hbm.xml to use mapping.xml
HHH-19433 - Deprecate @PropertyRef
1 parent 0abf2ae commit fc8040f

21 files changed

+406
-489
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
db=pgsql_ci
1+
db=mariadb_ci
22

33
# Keep all these properties in sync unless you know what you are doing!
44
# We set '-Dlog4j2.disableJmx=true' to prevent classloader leaks triggered by the logger.

hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/deletetransient/DeleteTransientEntityTest.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,16 @@
2424
/**
2525
* @author Steve Ebersole
2626
*/
27-
@DomainModel(
28-
xmlMappings = {
29-
"org/hibernate/orm/test/deletetransient/Person.hbm.xml"
30-
}
31-
)
27+
@SuppressWarnings("JUnitMalformedDeclaration")
28+
@DomainModel(xmlMappings = "org/hibernate/orm/test/deletetransient/Person.xml")
3229
@SessionFactory
3330
@BytecodeEnhanced
3431
@CustomEnhancementContext({ NoDirtyCheckingContext.class, DirtyCheckEnhancementContext.class })
3532
public class DeleteTransientEntityTest {
3633

3734
@AfterEach
3835
void tearDown(SessionFactoryScope scope) {
39-
scope.inTransaction( session -> session.createQuery( "from java.lang.Object", Object.class ).list().forEach( session::remove ) );
36+
scope.dropData();
4037
}
4138

4239
@Test

hibernate-core/src/test/java/org/hibernate/orm/test/connections/AggressiveReleaseTest.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@
44
*/
55
package org.hibernate.orm.test.connections;
66

7-
import java.sql.Connection;
8-
import java.util.ArrayList;
9-
import java.util.List;
10-
import java.util.Map;
11-
127
import org.hibernate.ScrollableResults;
138
import org.hibernate.Session;
149
import org.hibernate.cfg.AvailableSettings;
1510
import org.hibernate.cfg.Environment;
16-
import org.hibernate.dialect.H2Dialect;
1711
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
1812
import org.hibernate.internal.util.SerializationHelper;
1913
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
2014
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
2115
import org.hibernate.stat.Statistics;
22-
23-
import org.hibernate.testing.RequiresDialect;
2416
import org.hibernate.testing.jta.TestingJtaBootstrap;
2517
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
2618
import org.junit.Test;
2719

20+
import java.sql.Connection;
21+
import java.util.ArrayList;
22+
import java.util.List;
23+
import java.util.Map;
24+
2825
import static org.junit.Assert.assertEquals;
2926
import static org.junit.Assert.assertTrue;
3027
import static org.junit.Assert.fail;
@@ -34,7 +31,6 @@
3431
*
3532
* @author Steve Ebersole
3633
*/
37-
@RequiresDialect(H2Dialect.class)
3834
public class AggressiveReleaseTest extends ConnectionManagementTestCase {
3935
@Override
4036
protected void addSettings(Map<String,Object> settings) {

hibernate-core/src/test/java/org/hibernate/orm/test/connections/ConnectionManagementTestCase.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,9 @@
3131
*/
3232

3333
public abstract class ConnectionManagementTestCase extends BaseNonConfigCoreFunctionalTestCase {
34-
35-
@Override
36-
protected String getBaseForMappings() {
37-
return "org/hibernate/orm/test/";
38-
}
39-
4034
@Override
41-
public final String[] getMappings() {
42-
return new String[] { "connections/Silly.hbm.xml" };
35+
protected Class<?>[] getAnnotatedClasses() {
36+
return new Class<?>[] { Silly.class, Other.class };
4337
}
4438

4539

@@ -151,8 +145,11 @@ public final void testConnectedSerialization() throws Throwable {
151145
}
152146

153147
/**
154-
* Tests to validate that a session holding JDBC resources will not
148+
* Tests to validate that a session holding an enabled filter will not
155149
* be allowed to serialize.
150+
*
151+
* @apiNote This test is really misplaced as it has nothing to do with
152+
* connection-management nor even JDBC at all.
156153
*/
157154
@Test
158155
public final void testEnabledFilterSerialization() throws Throwable {

hibernate-core/src/test/java/org/hibernate/orm/test/connections/HibernateCreateBlobFailedCase.java

+19-27
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,37 @@
44
*/
55
package org.hibernate.orm.test.connections;
66

7+
import org.hibernate.Session;
8+
import org.hibernate.engine.spi.SessionFactoryImplementor;
9+
import org.hibernate.testing.orm.junit.DomainModel;
10+
import org.hibernate.testing.orm.junit.ServiceRegistry;
11+
import org.hibernate.testing.orm.junit.SessionFactory;
12+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
13+
import org.hibernate.testing.orm.junit.Setting;
14+
import org.junit.jupiter.api.Test;
15+
716
import java.sql.Blob;
817
import java.sql.Clob;
918
import java.sql.SQLException;
1019

11-
import org.junit.Test;
12-
13-
import org.hibernate.Session;
14-
import org.hibernate.cfg.Configuration;
15-
import org.hibernate.cfg.Environment;
16-
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
17-
18-
import static org.junit.Assert.assertFalse;
20+
import static org.hibernate.cfg.AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS;
21+
import static org.junit.jupiter.api.Assertions.assertFalse;
1922

2023
/**
2124
* Test originally developed to verify and fix HHH-5550
2225
*
2326
* @author Steve Ebersole
2427
*/
25-
public class HibernateCreateBlobFailedCase extends BaseCoreFunctionalTestCase {
26-
27-
@Override
28-
protected String getBaseForMappings() {
29-
return "org/hibernate/orm/test/";
30-
}
31-
32-
@Override
33-
public String[] getMappings() {
34-
return new String[] { "connections/Silly.hbm.xml" };
35-
}
36-
37-
@Override
38-
public void configure(Configuration cfg) {
39-
super.configure( cfg );
40-
cfg.setProperty( Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread" );
41-
}
28+
@SuppressWarnings("JUnitMalformedDeclaration")
29+
@ServiceRegistry(settings = @Setting( name=CURRENT_SESSION_CONTEXT_CLASS, value = "thread"))
30+
@DomainModel(annotatedClasses = { Silly.class, Other.class })
31+
@SessionFactory
32+
public class HibernateCreateBlobFailedCase {
4233

4334
@Test
44-
public void testLobCreation() throws SQLException {
45-
Session session = sessionFactory().getCurrentSession();
35+
public void testLobCreation(SessionFactoryScope factoryScope) throws SQLException {
36+
final SessionFactoryImplementor sessionFactory = factoryScope.getSessionFactory();
37+
Session session = sessionFactory.getCurrentSession();
4638
session.beginTransaction();
4739
Blob blob = session.getLobHelper().createBlob( new byte[] {} );
4840
blob.free();

hibernate-core/src/test/java/org/hibernate/orm/test/connections/Other.java

+7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
package org.hibernate.orm.test.connections;
66

77

8+
import jakarta.persistence.Entity;
9+
import jakarta.persistence.GeneratedValue;
10+
import jakarta.persistence.Id;
11+
812
/**
913
* @author Steve Ebersole
1014
*/
15+
@Entity
1116
public class Other {
17+
@Id
18+
@GeneratedValue(generator = "increment")
1219
private Long id;
1320
private String name;
1421

hibernate-core/src/test/java/org/hibernate/orm/test/connections/Silly.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@
33
* Copyright Red Hat Inc. and Hibernate Authors
44
*/
55
package org.hibernate.orm.test.connections;
6+
import jakarta.persistence.CascadeType;
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.GeneratedValue;
9+
import jakarta.persistence.Id;
10+
import jakarta.persistence.JoinColumn;
11+
import jakarta.persistence.ManyToOne;
12+
import org.hibernate.annotations.FilterDef;
13+
614
import java.io.Serializable;
715

816
/**
9-
* Implementation of Silly.
10-
*
1117
* @author Steve Ebersole
1218
*/
19+
@Entity
20+
@FilterDef(name = "nameIsNull", defaultCondition = "name is null")
1321
public class Silly implements Serializable {
22+
@Id
23+
@GeneratedValue(generator = "increment")
1424
private Long id;
1525
private String name;
26+
@ManyToOne(cascade = CascadeType.ALL)
27+
@JoinColumn
1628
private Other other;
1729

1830
public Silly() {

hibernate-core/src/test/java/org/hibernate/orm/test/deletetransient/Address.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
public class Address {
1515
private Long id;
1616
private String info;
17-
private Set suites = new HashSet();
17+
private Set<Suite> suites = new HashSet<>();
1818

1919
public Address() {
2020
}
@@ -39,11 +39,11 @@ public void setInfo(String info) {
3939
this.info = info;
4040
}
4141

42-
public Set getSuites() {
42+
public Set<Suite> getSuites() {
4343
return suites;
4444
}
4545

46-
public void setSuites(Set suites) {
46+
public void setSuites(Set<Suite> suites) {
4747
this.suites = suites;
4848
}
4949
}

0 commit comments

Comments
 (0)