Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
79ad91e
allow null value persistence and retrieval
NathanQingyangXu Jul 4, 2025
1c1d888
Merge branch 'main' into HIBERNATE-48
NathanQingyangXu Jul 11, 2025
4eb8a5d
bump hibernte version to v6.6.21 to enjoy some bugfixings
NathanQingyangXu Jul 15, 2025
d3cdce8
Merge remote-tracking branch 'origin/HIBERNATE-48' into HIBERNATE-48
NathanQingyangXu Jul 15, 2025
680a5c4
fix static check issue
NathanQingyangXu Jul 16, 2025
5a58a8c
Merge branch 'main' into HIBERNATE-48
NathanQingyangXu Jul 21, 2025
ebf9094
Update src/main/java/com/mongodb/hibernate/jdbc/MongoPreparedStatemen…
NathanQingyangXu Jul 22, 2025
092454e
change per code review comments
NathanQingyangXu Jul 22, 2025
61bd725
Merge remote-tracking branch 'origin/HIBERNATE-48' into HIBERNATE-48
NathanQingyangXu Jul 22, 2025
5da1980
bump hibernate ORM to 6.6.23 to enjoy bugfix of "empty struct loading…
NathanQingyangXu Jul 28, 2025
5634537
Merge branch 'main' into HIBERNATE-48
NathanQingyangXu Jul 28, 2025
e1fff5f
merge latest main and resolve conflict
NathanQingyangXu Jul 28, 2025
898909a
allow literal null value usage in AbstractMqlTranslator and update In…
NathanQingyangXu Jul 28, 2025
0b2286b
fix a legacy minor comment defect in StructAggregateEmbeddableIntegra…
NathanQingyangXu Jul 29, 2025
ca47f80
Update src/main/java/com/mongodb/hibernate/internal/type/MongoStructJ…
NathanQingyangXu Aug 13, 2025
3ac2844
resolve code review comments by Valentin
NathanQingyangXu Aug 13, 2025
f8484b6
Merge remote-tracking branch 'origin/HIBERNATE-48' into HIBERNATE-48
NathanQingyangXu Aug 13, 2025
30f59bf
make similar code changes to MongoPreparedStatement#parseParameters()
NathanQingyangXu Aug 13, 2025
612961a
change testReadNestedValuesMissingFields() by using reference field i…
NathanQingyangXu Aug 13, 2025
a5d8a37
Update src/integrationTest/java/com/mongodb/hibernate/ArrayAndCollect…
NathanQingyangXu Aug 13, 2025
f8e9017
fix static analysis
NathanQingyangXu Aug 13, 2025
1aba29e
Merge branch 'main' into HIBERNATE-48
NathanQingyangXu Aug 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ assertj = "3.27.3"
google-errorprone-core = "2.36.0"
nullaway = "0.12.4"
jspecify = "1.0.0"
hibernate-orm = "6.6.9.Final"
hibernate-orm = "6.6.21.Final"
mongo-java-driver-sync = "5.3.1"
slf4j-api = "2.0.16"
logback-classic = "1.5.16"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.mongodb.hibernate;

import static com.mongodb.hibernate.MongoTestAssertions.assertEq;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hibernate.cfg.AvailableSettings.WRAPPER_ARRAY_HANDLING;
Expand All @@ -41,13 +42,13 @@
import org.bson.types.ObjectId;
import org.hibernate.MappingException;
import org.hibernate.boot.MetadataSources;
import org.hibernate.exception.GenericJDBCException;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.SessionFactoryScopeAware;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -78,33 +79,32 @@ public void injectSessionFactoryScope(SessionFactoryScope sessionFactoryScope) {
void testArrayAndCollectionValues() {
var item = new ItemWithArrayAndCollectionValues(
1,
// TODO-HIBERNATE-48 sprinkle on `null` array/collection elements
new byte[] {2, 3},
new char[] {'s', 't', 'r'},
new int[] {5},
new long[] {Long.MAX_VALUE, 6},
new double[] {Double.MAX_VALUE},
new boolean[] {true},
new Character[] {'s', 't', 'r'},
new Integer[] {7},
new Long[] {8L},
new Double[] {9.1d},
new Boolean[] {true},
new String[] {"str"},
new BigDecimal[] {BigDecimal.valueOf(10.1)},
new ObjectId[] {new ObjectId("000000000000000000000001")},
new Character[] {'s', null, 't', 'r'},
new Integer[] {null, 7},
new Long[] {8L, null},
new Double[] {9.1d, null},
new Boolean[] {true, null},
new String[] {null, "str"},
new BigDecimal[] {null, BigDecimal.valueOf(10.1)},
new ObjectId[] {new ObjectId("000000000000000000000001"), null},
new StructAggregateEmbeddableIntegrationTests.Single[] {
new StructAggregateEmbeddableIntegrationTests.Single(1)
new StructAggregateEmbeddableIntegrationTests.Single(1), null
},
List.of('s', 't', 'r'),
List.of(5),
List.of(Long.MAX_VALUE, 6L),
List.of(Double.MAX_VALUE),
List.of(true),
List.of("str"),
List.of(BigDecimal.valueOf(10.1)),
List.of(new ObjectId("000000000000000000000001")),
List.of(new StructAggregateEmbeddableIntegrationTests.Single(1)));
asList('s', 't', null, 'r'),
asList(null, 5),
asList(Long.MAX_VALUE, null, 6L),
asList(null, Double.MAX_VALUE),
asList(null, true),
asList("str", null),
asList(BigDecimal.valueOf(10.1), null),
asList(null, new ObjectId("000000000000000000000001")),
asList(new StructAggregateEmbeddableIntegrationTests.Single(1), null));
sessionFactoryScope.inTransaction(session -> session.persist(item));
assertCollectionContainsExactly(
"""
Expand All @@ -116,24 +116,24 @@ void testArrayAndCollectionValues() {
longs: [{$numberLong: "9223372036854775807"}, {$numberLong: "6"}],
doubles: [{$numberDouble: "1.7976931348623157E308"}],
booleans: [true],
boxedChars: ["s", "t", "r"],
boxedInts: [7],
boxedLongs: [{$numberLong: "8"}],
boxedDoubles: [{$numberDouble: "9.1"}],
boxedBooleans: [true],
strings: ["str"],
bigDecimals: [{$numberDecimal: "10.1"}],
objectIds: [{$oid: "000000000000000000000001"}],
structAggregateEmbeddables: [{a: 1}],
charsCollection: ["s", "t", "r"],
intsCollection: [5],
longsCollection: [{$numberLong: "9223372036854775807"}, {$numberLong: "6"}],
doublesCollection: [{$numberDouble: "1.7976931348623157E308"}],
booleansCollection: [true],
stringsCollection: ["str"],
bigDecimalsCollection: [{$numberDecimal: "10.1"}],
objectIdsCollection: [{$oid: "000000000000000000000001"}],
structAggregateEmbeddablesCollection: [{a: 1}]
boxedChars: ["s", null, "t", "r"],
boxedInts: [null, 7],
boxedLongs: [{$numberLong: "8"}, null],
boxedDoubles: [{$numberDouble: "9.1"}, null],
boxedBooleans: [true, null],
strings: [null, "str"],
bigDecimals: [null, {$numberDecimal: "10.1"}],
objectIds: [{$oid: "000000000000000000000001"}, null],
structAggregateEmbeddables: [{a: 1}, null],
charsCollection: ["s", "t", null, "r"],
intsCollection: [null, 5],
longsCollection: [{$numberLong: "9223372036854775807"}, null, {$numberLong: "6"}],
doublesCollection: [null, {$numberDouble: "1.7976931348623157E308"}],
booleansCollection: [null, true],
stringsCollection: ["str", null],
bigDecimalsCollection: [{$numberDecimal: "10.1"}, null],
objectIdsCollection: [null, {$oid: "000000000000000000000001"}],
structAggregateEmbeddablesCollection: [{a: 1}, null]
}
""");
var loadedItem = sessionFactoryScope.fromTransaction(
Expand All @@ -158,24 +158,24 @@ void testArrayAndCollectionValues() {
longs: [{$numberLong: "9223372036854775807"}, {$numberLong: "-6"}],
doubles: [{$numberDouble: "1.7976931348623157E308"}],
booleans: [true],
boxedChars: ["s", "t", "r"],
boxedInts: [7],
boxedLongs: [{$numberLong: "8"}],
boxedDoubles: [{$numberDouble: "9.1"}],
boxedBooleans: [true],
strings: ["str"],
bigDecimals: [{$numberDecimal: "10.1"}],
objectIds: [{$oid: "000000000000000000000002"}],
structAggregateEmbeddables: [{a: 1}],
charsCollection: ["s", "t", "r"],
intsCollection: [5],
longsCollection: [{$numberLong: "9223372036854775807"}, {$numberLong: "-6"}],
doublesCollection: [{$numberDouble: "1.7976931348623157E308"}],
booleansCollection: [true],
stringsCollection: ["str"],
bigDecimalsCollection: [{$numberDecimal: "10.1"}],
objectIdsCollection: [{$oid: "000000000000000000000001"}],
structAggregateEmbeddablesCollection: [{a: 1}]
boxedChars: ["s", null, "t", "r"],
boxedInts: [null, 7],
boxedLongs: [{$numberLong: "8"}, null],
boxedDoubles: [{$numberDouble: "9.1"}, null],
boxedBooleans: [true, null],
strings: [null, "str"],
bigDecimals: [null, {$numberDecimal: "10.1"}],
objectIds: [{$oid: "000000000000000000000002"}, null],
structAggregateEmbeddables: [{a: 1}, null],
charsCollection: ["s", "t", null, "r"],
intsCollection: [null, 5],
longsCollection: [{$numberLong: "9223372036854775807"}, null, {$numberLong: "-6"}],
doublesCollection: [null, {$numberDouble: "1.7976931348623157E308"}],
booleansCollection: [null, true],
stringsCollection: ["str", null],
bigDecimalsCollection: [{$numberDecimal: "10.1"}, null],
objectIdsCollection: [null, {$oid: "000000000000000000000001"}],
structAggregateEmbeddablesCollection: [{a: 1}, null]
}
""");
loadedItem = sessionFactoryScope.fromTransaction(
Expand Down Expand Up @@ -248,7 +248,6 @@ void testArrayAndCollectionEmptyValues() {
}

@Test
@Disabled("TODO-HIBERNATE-48 https://jira.mongodb.org/browse/HIBERNATE-48 enable this test")
void testArrayAndCollectionNullValues() {
var item = new ItemWithArrayAndCollectionValues(
1, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
Expand Down Expand Up @@ -410,7 +409,6 @@ void testArrayAndCollectionValuesOfStructAggregateEmbeddablesHavingArraysAndColl
* @see StructAggregateEmbeddableIntegrationTests#testNestedValueHavingNullArraysAndCollections()
*/
@Test
@Disabled("TODO-HIBERNATE-48 https://jira.mongodb.org/browse/HIBERNATE-48 enable this test")
public void testArrayAndCollectionValuesOfEmptyStructAggregateEmbeddables() {
var emptyStructAggregateEmbeddable = new ArraysAndCollections(
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
Expand Down Expand Up @@ -597,16 +595,13 @@ static class ItemWithArrayAndCollectionValuesOfStructAggregateEmbeddablesHavingA

@Nested
class Unsupported {
/**
* The {@link ClassCastException} caught here manifests a Hibernate ORM bug. The issue goes away if the
* {@link ItemWithBoxedBytesArrayValue#bytes} field is removed. Otherwise, the behavior of this test should have
* been equivalent to {@link #testBytesCollectionValue()}.
*/

@Test
void testBoxedBytesArrayValue() {
var item = new ItemWithBoxedBytesArrayValue(1, new byte[] {1}, new Byte[] {2});
assertThatThrownBy(() -> sessionFactoryScope.inTransaction(session -> session.persist(item)))
.isInstanceOf(ClassCastException.class);
.isInstanceOf(GenericJDBCException.class)
.hasCauseInstanceOf(SQLFeatureNotSupportedException.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.SessionFactoryScopeAware;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -97,7 +96,6 @@ void testSimpleEntityInsertion() {
}

@Test
@Disabled("TODO-HIBERNATE-48 https://jira.mongodb.org/browse/HIBERNATE-48 enable this test")
void testEntityWithNullFieldValuesInsertion() {
sessionFactoryScope.inTransaction(session -> session.persist(new Item(
1,
Expand Down Expand Up @@ -218,7 +216,6 @@ void testSimpleUpdate() {
}

@Test
@Disabled("TODO-HIBERNATE-48 https://jira.mongodb.org/browse/HIBERNATE-48 enable this test")
void testSimpleUpdateWithNullFieldValues() {
sessionFactoryScope.inTransaction(session -> {
var item = new Item(
Expand Down Expand Up @@ -290,7 +287,6 @@ void testDynamicUpdate() {
}

@Test
@Disabled("TODO-HIBERNATE-48 https://jira.mongodb.org/browse/HIBERNATE-48 enable this test")
void testDynamicUpdateWithNullFieldValues() {
sessionFactoryScope.inTransaction(session -> {
var item = new ItemDynamicallyUpdated(1, false, true);
Expand Down Expand Up @@ -337,7 +333,6 @@ void testFindByPrimaryKey() {
}

@Test
@Disabled("TODO-HIBERNATE-48 https://jira.mongodb.org/browse/HIBERNATE-48 enable this test")
void testFindByPrimaryKeyWithNullFieldValues() {
var item = new Item(
1, 'c', 1, Long.MAX_VALUE, Double.MAX_VALUE, true, null, null, null, null, null, null, null, null);
Expand Down
Loading