Skip to content

Commit 792f6d5

Browse files
MoadElfatihigavinking
authored andcommitted
HHH-19810 remove joda dependency
1 parent f8151bf commit 792f6d5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

hibernate-core/hibernate-core.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ dependencies {
5757
// for test runtime
5858
transitive = true
5959
}
60-
testImplementation "joda-time:joda-time:2.3"
6160
testImplementation jdbcLibs.h2
6261
testImplementation libs.hibernateModelsJandex
6362

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package org.hibernate.orm.test.mapping.converted.converter;
66

77
import java.net.MalformedURLException;
8-
import java.util.Date;
8+
import java.time.LocalDate;
99
import jakarta.persistence.AttributeConverter;
1010
import jakarta.persistence.Convert;
1111
import jakarta.persistence.Entity;
@@ -21,7 +21,6 @@
2121
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
2222
import org.junit.Test;
2323

24-
import org.joda.time.LocalDate;
2524

2625
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
2726
import static org.junit.Assert.assertTrue;
@@ -30,7 +29,7 @@
3029
* @author Steve Ebersole
3130
*/
3231
@JiraKey( value = "HHH-8842" )
33-
public class BasicJodaTimeConversionTest extends BaseNonConfigCoreFunctionalTestCase {
32+
public class BasicCustomTimeConversionTest extends BaseNonConfigCoreFunctionalTestCase {
3433
static boolean convertToDatabaseColumnCalled = false;
3534
static boolean convertToEntityAttributeCalled = false;
3635

@@ -39,29 +38,31 @@ private void resetFlags() {
3938
convertToEntityAttributeCalled = false;
4039
}
4140

42-
public static class JodaLocalDateConverter implements AttributeConverter<LocalDate, Date> {
43-
public Date convertToDatabaseColumn(LocalDate localDate) {
41+
public record CustomLocalDate(int year,int month,int day) { }
42+
43+
public static class CustomLocalDateConverter implements AttributeConverter<CustomLocalDate, LocalDate> {
44+
public LocalDate convertToDatabaseColumn(CustomLocalDate customLocalDate) {
4445
convertToDatabaseColumnCalled = true;
45-
return localDate.toDate();
46+
return LocalDate.of(customLocalDate.year(),customLocalDate.month(), customLocalDate.day() );
4647
}
4748

48-
public LocalDate convertToEntityAttribute(Date date) {
49+
public CustomLocalDate convertToEntityAttribute(LocalDate date) {
4950
convertToEntityAttributeCalled = true;
50-
return LocalDate.fromDateFields( date );
51+
return new CustomLocalDate( date.getYear(), date.getMonthValue(), date.getDayOfMonth());
5152
}
5253
}
5354

5455
@Entity( name = "TheEntity" )
5556
public static class TheEntity {
5657
@Id
5758
public Integer id;
58-
@Convert( converter = JodaLocalDateConverter.class )
59-
public LocalDate theDate;
59+
@Convert( converter = CustomLocalDateConverter.class )
60+
public CustomLocalDate theDate;
6061

6162
public TheEntity() {
6263
}
6364

64-
public TheEntity(Integer id, LocalDate theDate) {
65+
public TheEntity(Integer id, CustomLocalDate theDate) {
6566
this.id = id;
6667
this.theDate = theDate;
6768
}
@@ -78,13 +79,13 @@ public void testSimpleConvertUsage() throws MalformedURLException {
7879
final Type theDatePropertyType = ep.getPropertyType( "theDate" );
7980
final ConvertedBasicTypeImpl type = assertTyping( ConvertedBasicTypeImpl.class, theDatePropertyType );
8081
final JpaAttributeConverter converter = (JpaAttributeConverter) type.getValueConverter();
81-
assertTrue( JodaLocalDateConverter.class.isAssignableFrom( converter.getConverterJavaType().getJavaTypeClass() ) );
82+
assertTrue( CustomLocalDateConverter.class.isAssignableFrom( converter.getConverterJavaType().getJavaTypeClass() ) );
8283

8384
resetFlags();
8485

8586
Session session = openSession();
8687
session.getTransaction().begin();
87-
session.persist( new TheEntity( 1, new LocalDate() ) );
88+
session.persist( new TheEntity( 1, new CustomLocalDate( 2025, 9, 26 ) ) );
8889
session.getTransaction().commit();
8990
session.close();
9091

0 commit comments

Comments
 (0)