Skip to content

Commit 64a524b

Browse files
authored
Update Hibernate 5.x/6.x deps to later/-st (#179)
1 parent 2891994 commit 64a524b

File tree

17 files changed

+175
-153
lines changed

17 files changed

+175
-153
lines changed

.mvn/wrapper/maven-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip
18-
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar

hibernate4/src/test/java/com/fasterxml/jackson/datatype/hibernate4/BaseTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.util.Arrays;
44

55
import com.fasterxml.jackson.databind.ObjectMapper;
6-
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;
76

87
import static org.junit.jupiter.api.Assertions.fail;
98

hibernate4/src/test/java/com/fasterxml/jackson/datatype/hibernate4/ReplacePersistentCollectionTest.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.JsonMappingException;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import com.fasterxml.jackson.databind.json.JsonMapper;
56
import com.fasterxml.jackson.datatype.hibernate4.data.Customer;
67
import com.fasterxml.jackson.datatype.hibernate4.data.Payment;
78
import org.hibernate.Hibernate;
@@ -37,10 +38,9 @@ public void tearDown() throws Exception {
3738
// [Issue#93], backwards compatible case
3839
@Test
3940
public void testNoReplacePersistentCollection() throws Exception {
40-
final ObjectMapper mapper = new ObjectMapper()
41-
.registerModule(new Hibernate4Module()
41+
final ObjectMapper mapper = hibernateMapper(new Hibernate4Module()
4242
.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, true)
43-
).enableDefaultTyping();
43+
);
4444

4545
Customer customer = em.find(Customer.class, 103);
4646
assertFalse(Hibernate.isInitialized(customer.getPayments()));
@@ -60,7 +60,7 @@ public void testNoReplacePersistentCollection() throws Exception {
6060

6161
boolean exceptionThrown = false;
6262
try {
63-
Map<?, ?> stuff = mapper.readValue(json, Map.class);
63+
/*Map<?, ?> stuff =*/ mapper.readValue(json, Map.class);
6464
} catch (JsonMappingException e) {
6565
exceptionThrown = true;
6666
}
@@ -70,11 +70,9 @@ public void testNoReplacePersistentCollection() throws Exception {
7070
// [Issue#93], backwards compatible case
7171
@Test
7272
public void testReplacePersistentCollection() throws Exception {
73-
final ObjectMapper mapper = new ObjectMapper()
74-
.registerModule(new Hibernate4Module()
73+
final ObjectMapper mapper = hibernateMapper(new Hibernate4Module()
7574
.configure(Hibernate4Module.Feature.FORCE_LAZY_LOADING, true)
76-
.configure(Hibernate4Module.Feature.REPLACE_PERSISTENT_COLLECTIONS, true)
77-
).enableDefaultTyping();
75+
.configure(Hibernate4Module.Feature.REPLACE_PERSISTENT_COLLECTIONS, true));
7876

7977
Customer customer = em.find(Customer.class, 103);
8078
assertFalse(Hibernate.isInitialized(customer.getPayments()));
@@ -99,7 +97,7 @@ public void testReplacePersistentCollection() throws Exception {
9997

10098
boolean issue94failed = false;
10199
try {
102-
Map<?, ?> stuff = mapper.readValue(json, Map.class);
100+
/* Map<?, ?> stuff =*/ mapper.readValue(json, Map.class);
103101
} catch (JsonMappingException e) {
104102
issue94failed = true;
105103
}
@@ -112,4 +110,11 @@ public void testReplacePersistentCollection() throws Exception {
112110
// assertTrue(stuff.containsKey("orders"));
113111
// assertNull(stuff.get("orderes"));
114112
}
113+
114+
private ObjectMapper hibernateMapper(Hibernate4Module module) {
115+
return JsonMapper.builder()
116+
.addModule(module)
117+
.build()
118+
.enableDefaultTyping();
119+
}
115120
}

hibernate4/src/test/resources/classicmodels.sql

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ CREATE TABLE `classicmodels`.`Customer` (
3333
`contactFirstName` varchar(50) NOT NULL,
3434
`phone` varchar(50) NOT NULL,
3535
`addressLine1` varchar(50) NOT NULL,
36-
`addressLine2` varchar(50) DEFAULT NULL,
36+
`addressLine2` varchar(50),
3737
`city` varchar(50) NOT NULL,
38-
`state` varchar(50) DEFAULT NULL,
39-
`postalCode` varchar(15) DEFAULT NULL,
38+
`state` varchar(50),
39+
`postalCode` varchar(15) ,
4040
`country` varchar(50) NOT NULL,
41-
`salesRepEmployeeNumber` int(11) DEFAULT NULL,
42-
`creditLimit` double DEFAULT NULL,
43-
`missingProductCode` varchar(50) NULL,
41+
`salesRepEmployeeNumber` int(11),
42+
`creditLimit` double,
43+
`missingProductCode` varchar(50),
4444
PRIMARY KEY (`customerNumber`)
45-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
45+
);
4646
INSERT INTO `classicmodels`.`Customer` (`customerNumber`,`customerName`,`contactLastName`,`contactFirstName`,`phone`,`addressLine1`,`addressLine2`,`city`,`state`,`postalCode`,`country`,`salesRepEmployeeNumber`,`creditLimit`) VALUES
4747
(103,'Atelier graphique','Schmitt','Carine ','40.32.2555','54, rue Royale',NULL,'Nantes',NULL,'44000','France',1370,21000),
4848
(112,'Signal Gift Stores','King','Sue','7025551838','8489 Strong St.',NULL,'Las Vegas','NV','83030','USA',1166,71800),
@@ -168,7 +168,7 @@ INSERT INTO `classicmodels`.`Customer` (`customerNumber`,`customerName`,`contact
168168
(496,'Kellys Gift Shop','Snowden','Tony','+64 9 5555500','Arenales 1938 3A',NULL,'Auckland ',NULL,'','New Zealand',1612,110000);
169169
INSERT INTO `classicmodels`.`Customer` (`customerNumber`,`customerName`,`contactLastName`,`contactFirstName`,`phone`,`addressLine1`,`addressLine2`,`city`,`state`,`postalCode`,`country`,`salesRepEmployeeNumber`,`creditLimit`, `missingProductCode`) VALUES
170170
(500,'Customer with valid product','Schmitt','Carine ','40.32.2555','54, rue Royale',NULL,'Nantes',NULL,'44000','France',1370,21000, 'S10_1678'),
171-
(501,'Customer with invalid product','Schmitt','Carine ','40.32.2555','54, rue Royale',NULL,'Nantes',NULL,'44000','France',1370,21000, 'X10_1678'),
171+
(501,'Customer with invalid product','Schmitt','Carine ','40.32.2555','54, rue Royale',NULL,'Nantes',NULL,'44000','France',1370,21000, 'X10_1678');
172172

173173
DROP TABLE IF EXISTS `classicmodels`.`Employee`;
174174
CREATE TABLE `classicmodels`.`Employee` (
@@ -178,10 +178,10 @@ CREATE TABLE `classicmodels`.`Employee` (
178178
`extension` varchar(10) NOT NULL,
179179
`email` varchar(100) NOT NULL,
180180
`officeCode` varchar(50) NOT NULL,
181-
`reportsTo` int(11) DEFAULT NULL,
181+
`reportsTo` int(11) ,
182182
`jobTitle` varchar(50) NOT NULL,
183183
PRIMARY KEY (`employeeNumber`)
184-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
184+
);
185185
INSERT INTO `classicmodels`.`Employee` (`employeeNumber`,`lastName`,`firstName`,`extension`,`email`,`officeCode`,`reportsTo`,`jobTitle`) VALUES
186186
(1002,'Murphy','Diane','x5800','dmurphy@classicmodelcars.com','1',NULL,'President'),
187187
(1056,'Patterson','Mary','x4611','mpatterso@classicmodelcars.com','1',1002,'VP Sales'),
@@ -213,13 +213,13 @@ CREATE TABLE `classicmodels`.`Office` (
213213
`city` varchar(50) NOT NULL,
214214
`phone` varchar(50) NOT NULL,
215215
`addressLine1` varchar(50) NOT NULL,
216-
`addressLine2` varchar(50) DEFAULT NULL,
217-
`state` varchar(50) DEFAULT NULL,
216+
`addressLine2` varchar(50) ,
217+
`state` varchar(50) ,
218218
`country` varchar(50) NOT NULL,
219219
`postalCode` varchar(10) NOT NULL,
220220
`territory` varchar(10) NOT NULL,
221221
PRIMARY KEY (`officeCode`)
222-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
222+
);
223223
INSERT INTO `classicmodels`.`Office` (`officeCode`,`city`,`phone`,`addressLine1`,`addressLine2`,`state`,`country`,`postalCode`,`territory`) VALUES
224224
('1','San Francisco','+1 650 219 4782','100 Market Street','Suite 300','CA','USA','94080','NA'),
225225
('2','Boston','+1 215 837 0825','1550 Court Place','Suite 102','MA','USA','02107','NA'),
@@ -234,12 +234,12 @@ CREATE TABLE `classicmodels`.`Order` (
234234
`orderNumber` int(11) NOT NULL,
235235
`orderDate` datetime NOT NULL,
236236
`requiredDate` datetime NOT NULL,
237-
`shippedDate` datetime DEFAULT NULL,
237+
`shippedDate` datetime ,
238238
`status` varchar(15) NOT NULL,
239239
`comments` text,
240240
`customerNumber` int(11) NOT NULL,
241241
PRIMARY KEY (`orderNumber`)
242-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
242+
);
243243
INSERT INTO `classicmodels`.`Order` (`orderNumber`,`orderDate`,`requiredDate`,`shippedDate`,`status`,`comments`,`customerNumber`) VALUES
244244
(10100,'2003-01-06 00:00:00','2003-01-13 00:00:00','2003-01-10 00:00:00','Shipped',NULL,363),
245245
(10101,'2003-01-09 00:00:00','2003-01-18 00:00:00','2003-01-11 00:00:00','Shipped','Check on availability.',128),
@@ -576,7 +576,7 @@ CREATE TABLE `classicmodels`.`OrderDetail` (
576576
`priceEach` double NOT NULL,
577577
`orderLineNumber` smallint(6) NOT NULL,
578578
PRIMARY KEY (`orderNumber`,`productCode`)
579-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
579+
);
580580
INSERT INTO `classicmodels`.`OrderDetail` (`orderNumber`,`productCode`,`quantityOrdered`,`priceEach`,`orderLineNumber`) VALUES
581581
(10100,'S18_1749',30,171.7,3),
582582
(10100,'S18_2248',50,67.8,2),
@@ -3583,7 +3583,7 @@ CREATE TABLE `classicmodels`.`Payment` (
35833583
`paymentDate` datetime NOT NULL,
35843584
`amount` double NOT NULL,
35853585
PRIMARY KEY (`customerNumber`,`checkNumber`)
3586-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3586+
);
35873587
INSERT INTO `classicmodels`.`Payment` (`customerNumber`,`checkNumber`,`paymentDate`,`amount`) VALUES
35883588
(103,'HQ336336','2004-10-19 00:00:00',5307.98),
35893589
(103,'JM555205','2003-06-05 00:00:00',16560.3),
@@ -3870,7 +3870,7 @@ CREATE TABLE `classicmodels`.`Product` (
38703870
`buyPrice` double NOT NULL,
38713871
`MSRP` double NOT NULL,
38723872
PRIMARY KEY (`productCode`)
3873-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3873+
);
38743874
INSERT INTO `classicmodels`.`Product` (`productCode`,`productName`,`productLine`,`productScale`,`productVendor`,`productDescription`,`quantityInStock`,`buyPrice`,`MSRP`) VALUES
38753875
('S10_1678','1969 Harley Davidson Ultimate Chopper','Motorcycles','1:10','Min Lin Diecast','This replica features working kickstand, front suspension, gear-shift lever, footbrake lever, drive chain, wheels and steering. All parts are particularly delicate due to their precise scale and require special care and attention.',7933,48.81,95.7),
38763876
('S10_1949','1952 Alpine Renault 1300','Classic Cars','1:10','Classic Metal Creations','Turnable front wheels; steering function; detailed interior; detailed engine; opening hood; opening trunk; opening doors; and detailed chassis.',7305,98.58,214.3),
@@ -3989,7 +3989,7 @@ CREATE TABLE `classicmodels`.`Contrato` (
39893989
`id` numeric(10) NOT NULL,
39903990
`numero_contrato` varchar(50) NOT NULL,
39913991
PRIMARY KEY (`id`)
3992-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3992+
);
39933993
INSERT INTO `classicmodels`.`Contrato` (`id`,`numero_contrato`) VALUES
39943994
(1, '100001-9');
39953995

@@ -3999,7 +3999,7 @@ CREATE TABLE `classicmodels`.`Parcela` (
39993999
`numero_parcela` numeric(10) NOT NULL,
40004000
`contrato_id` numeric(10) NOT NULL,
40014001
PRIMARY KEY (`id`)
4002-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4002+
);
40034003
INSERT INTO `classicmodels`.`Parcela` (`id`,`numero_parcela`,`contrato_id`) VALUES
40044004
(1, 1, 1);
40054005

@@ -4010,7 +4010,7 @@ CREATE TABLE `classicmodels`.`Liquidacao` (
40104010
`contrato_id` numeric(10) NOT NULL,
40114011
`parcela_id` numeric(10) NULL,
40124012
PRIMARY KEY (`id`)
4013-
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4013+
);
40144014
INSERT INTO `classicmodels`.`Liquidacao` (`id`,`valor_total`,`contrato_id`, `parcela_id`) VALUES
40154015
(1, 10000, 1, 1);
40164016

hibernate5-jakarta/src/test/java/com/fasterxml/jackson/datatype/hibernate5/jakarta/ReplacePersistentCollectionTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.fasterxml.jackson.databind.JsonMappingException;
88
import com.fasterxml.jackson.databind.ObjectMapper;
99
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
10+
import com.fasterxml.jackson.databind.json.JsonMapper;
1011
import com.fasterxml.jackson.datatype.hibernate5.jakarta.data.Customer;
1112
import com.fasterxml.jackson.datatype.hibernate5.jakarta.data.Payment;
1213

@@ -39,10 +40,9 @@ public void tearDown() throws Exception {
3940
// [Issue#93], backwards compatible case
4041
@Test
4142
public void testNoReplacePersistentCollection() throws Exception {
42-
final ObjectMapper mapper = new ObjectMapper()
43-
.registerModule(new Hibernate5JakartaModule()
43+
final ObjectMapper mapper = hibernateMapper(new Hibernate5JakartaModule()
4444
.configure(Hibernate5JakartaModule.Feature.FORCE_LAZY_LOADING, true)
45-
).enableDefaultTyping(DefaultTyping.NON_FINAL);
45+
);
4646

4747
Customer customer = em.find(Customer.class, 103);
4848
assertFalse(Hibernate.isInitialized(customer.getPayments()));
@@ -63,11 +63,10 @@ public void testNoReplacePersistentCollection() throws Exception {
6363
// [Issue#93], backwards compatible case
6464
@Test
6565
public void testReplacePersistentCollection() throws Exception {
66-
final ObjectMapper mapper = new ObjectMapper()
67-
.registerModule(new Hibernate5JakartaModule()
66+
final ObjectMapper mapper = hibernateMapper(new Hibernate5JakartaModule()
6867
.configure(Hibernate5JakartaModule.Feature.FORCE_LAZY_LOADING, true)
6968
.configure(Hibernate5JakartaModule.Feature.REPLACE_PERSISTENT_COLLECTIONS, true)
70-
).enableDefaultTyping(DefaultTyping.NON_FINAL);
69+
);
7170

7271
Customer customer = em.find(Customer.class, 103);
7372
assertFalse(Hibernate.isInitialized(customer.getPayments()));
@@ -86,4 +85,11 @@ public void testReplacePersistentCollection() throws Exception {
8685
// assertTrue(stuff.containsKey("orders"));
8786
// assertNull(stuff.get("orderes"));
8887
}
88+
89+
private ObjectMapper hibernateMapper(Hibernate5JakartaModule module) {
90+
return JsonMapper.builder()
91+
.addModule(module)
92+
.build()
93+
.enableDefaultTyping(DefaultTyping.NON_FINAL);
94+
}
8995
}

0 commit comments

Comments
 (0)