Skip to content

Commit 04a64dc

Browse files
committed
Support array, array_list, array_contains/*_nullable, array_includes/*_nullable
HIBERNATE-63
1 parent 23ad2b4 commit 04a64dc

File tree

57 files changed

+1356
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1356
-84
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# limitations under the License.
1414

1515
[versions]
16-
junit-jupiter = "5.11.4"
16+
junit-jupiter = "5.13.4"
1717
assertj = "3.27.3"
1818
google-errorprone-core = "2.36.0"
1919
nullaway = "0.12.4"
2020
jspecify = "1.0.0"
21-
hibernate-orm = "6.6.23.Final"
21+
hibernate-orm = "6.6.25.Final"
2222
mongo-java-driver-sync = "5.3.1"
2323
slf4j-api = "2.0.16"
2424
logback-classic = "1.5.16"

src/integrationTest/java/com/mongodb/hibernate/ArrayAndCollectionIntegrationTests.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
@ServiceRegistry(settings = {@Setting(name = WRAPPER_ARRAY_HANDLING, value = "allow")})
6565
@ExtendWith(MongoExtension.class)
6666
public class ArrayAndCollectionIntegrationTests implements SessionFactoryScopeAware {
67-
@InjectMongoCollection("items")
67+
private static final String COLLECTION_NAME = "items";
68+
69+
@InjectMongoCollection(COLLECTION_NAME)
6870
private static MongoCollection<BsonDocument> mongoCollection;
6971

7072
private SessionFactoryScope sessionFactoryScope;
@@ -485,7 +487,7 @@ private static void assertCollectionContainsExactly(String documentAsJsonObject)
485487
}
486488

487489
@Entity
488-
@Table(name = "items")
490+
@Table(name = COLLECTION_NAME)
489491
static class ItemWithArrayAndCollectionValues {
490492
@Id
491493
int id;
@@ -572,7 +574,7 @@ static class ItemWithArrayAndCollectionValues {
572574
}
573575

574576
@Entity
575-
@Table(name = "items")
577+
@Table(name = COLLECTION_NAME)
576578
static class ItemWithArrayAndCollectionValuesOfStructAggregateEmbeddablesHavingArraysAndCollections {
577579
@Id
578580
int id;
@@ -662,7 +664,7 @@ void testCollectionOfEmbeddablesElementCollectionValue() {
662664
}
663665

664666
@Entity
665-
@Table(name = "items")
667+
@Table(name = COLLECTION_NAME)
666668
static class ItemWithBoxedBytesArrayValue {
667669
@Id
668670
int id;
@@ -680,7 +682,7 @@ static class ItemWithBoxedBytesArrayValue {
680682
}
681683

682684
@Entity
683-
@Table(name = "items")
685+
@Table(name = COLLECTION_NAME)
684686
static class ItemWithBytesCollectionValue {
685687
@Id
686688
int id;
@@ -702,7 +704,7 @@ static class ItemWithBytesCollectionValue {
702704
* example.</a>
703705
*/
704706
@Entity
705-
@Table(name = "items")
707+
@Table(name = COLLECTION_NAME)
706708
static class ItemWithNestedArrayValue {
707709
@Id
708710
int id;
@@ -717,7 +719,7 @@ static class ItemWithNestedArrayValue {
717719
* example.</a>
718720
*/
719721
@Entity
720-
@Table(name = "items")
722+
@Table(name = COLLECTION_NAME)
721723
static class ItemWithNestedCollectionValue {
722724
@Id
723725
int id;
@@ -726,7 +728,7 @@ static class ItemWithNestedCollectionValue {
726728
}
727729

728730
@Entity
729-
@Table(name = "items")
731+
@Table(name = COLLECTION_NAME)
730732
static class ItemWithArrayOfEmbeddablesValue {
731733
@Id
732734
int id;
@@ -735,7 +737,7 @@ static class ItemWithArrayOfEmbeddablesValue {
735737
}
736738

737739
@Entity
738-
@Table(name = "items")
740+
@Table(name = COLLECTION_NAME)
739741
static class ItemWithCollectionOfEmbeddablesValue {
740742
@Id
741743
int id;
@@ -744,7 +746,7 @@ static class ItemWithCollectionOfEmbeddablesValue {
744746
}
745747

746748
@Entity
747-
@Table(name = "items")
749+
@Table(name = COLLECTION_NAME)
748750
static class ItemWithArrayOfEmbeddablesElementCollectionValue {
749751
@Id
750752
int id;
@@ -754,7 +756,7 @@ static class ItemWithArrayOfEmbeddablesElementCollectionValue {
754756
}
755757

756758
@Entity
757-
@Table(name = "items")
759+
@Table(name = COLLECTION_NAME)
758760
static class ItemWithCollectionOfEmbeddablesElementCollectionValue {
759761
@Id
760762
int id;

src/integrationTest/java/com/mongodb/hibernate/BasicCrudIntegrationTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
})
4545
@ExtendWith(MongoExtension.class)
4646
class BasicCrudIntegrationTests implements SessionFactoryScopeAware {
47+
private static final String COLLECTION_NAME = "items";
4748

48-
@InjectMongoCollection("items")
49+
@InjectMongoCollection(COLLECTION_NAME)
4950
private static MongoCollection<BsonDocument> mongoCollection;
5051

5152
private SessionFactoryScope sessionFactoryScope;
@@ -348,7 +349,7 @@ private static void assertCollectionContainsExactly(String documentAsJsonObject)
348349
}
349350

350351
@Entity
351-
@Table(name = "items")
352+
@Table(name = COLLECTION_NAME)
352353
static class Item {
353354
@Id
354355
int id;
@@ -402,7 +403,7 @@ static class Item {
402403
}
403404

404405
@Entity
405-
@Table(name = "items")
406+
@Table(name = COLLECTION_NAME)
406407
static class ItemDynamicallyUpdated {
407408
@Id
408409
int id;

src/integrationTest/java/com/mongodb/hibernate/boot/JakartaPersistenceBootstrappingIntegrationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
annotatedClasses = JakartaPersistenceBootstrappingIntegrationTests.Item.class)
4242
@ExtendWith(MongoExtension.class)
4343
class JakartaPersistenceBootstrappingIntegrationTests {
44+
private static final String COLLECTION_NAME = "items";
4445

45-
@InjectMongoCollection("items")
46+
@InjectMongoCollection(COLLECTION_NAME)
4647
private static MongoCollection<BsonDocument> mongoCollection;
4748

4849
@Test
@@ -56,7 +57,7 @@ void smoke(EntityManagerFactoryScope scope) {
5657
}
5758

5859
@Entity
59-
@Table(name = "items")
60+
@Table(name = COLLECTION_NAME)
6061
static class Item {
6162
@Id
6263
int id;

src/integrationTest/java/com/mongodb/hibernate/embeddable/EmbeddableIntegrationTests.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
})
6464
@ExtendWith(MongoExtension.class)
6565
public class EmbeddableIntegrationTests implements SessionFactoryScopeAware {
66-
@InjectMongoCollection("items")
66+
private static final String COLLECTION_NAME = "items";
67+
68+
@InjectMongoCollection(COLLECTION_NAME)
6769
private static MongoCollection<BsonDocument> mongoCollection;
6870

6971
private SessionFactoryScope sessionFactoryScope;
@@ -503,7 +505,7 @@ private static void assertCollectionContainsExactly(String documentAsJsonObject)
503505
}
504506

505507
@Entity
506-
@Table(name = "items")
508+
@Table(name = COLLECTION_NAME)
507509
static class ItemWithFlattenedValues {
508510
@Id
509511
Single flattenedId;
@@ -596,7 +598,7 @@ record Plural(
596598
ObjectId objectId) {}
597599

598600
@Entity
599-
@Table(name = "items")
601+
@Table(name = COLLECTION_NAME)
600602
static class ItemWithFlattenedValueHavingArraysAndCollections {
601603
@Id
602604
int id;
@@ -723,14 +725,14 @@ void testNoPersistentAttributes() {
723725
}
724726

725727
@Entity
726-
@Table(name = "items")
728+
@Table(name = COLLECTION_NAME)
727729
static class ItemWithPluralAsId {
728730
@Id
729731
Plural id;
730732
}
731733

732734
@Entity
733-
@Table(name = "items")
735+
@Table(name = COLLECTION_NAME)
734736
static class ItemWithFlattenedValueHavingStructAggregateEmbeddable {
735737
@Id
736738
int id;
@@ -748,7 +750,7 @@ static class ItemWithFlattenedValueHavingStructAggregateEmbeddable {
748750
record SingleHavingStructAggregateEmbeddable(StructAggregateEmbeddableIntegrationTests.Single nested) {}
749751

750752
@Entity
751-
@Table(name = "items")
753+
@Table(name = COLLECTION_NAME)
752754
static class ItemWithFlattenedValueHavingNoPersistentAttributes {
753755
@Id
754756
int id;

src/integrationTest/java/com/mongodb/hibernate/embeddable/StructAggregateEmbeddableIntegrationTests.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
})
6363
@ExtendWith(MongoExtension.class)
6464
public class StructAggregateEmbeddableIntegrationTests implements SessionFactoryScopeAware {
65-
@InjectMongoCollection("items")
65+
private static final String COLLECTION_NAME = "items";
66+
67+
@InjectMongoCollection(COLLECTION_NAME)
6668
private static MongoCollection<BsonDocument> mongoCollection;
6769

6870
private SessionFactoryScope sessionFactoryScope;
@@ -514,7 +516,7 @@ private static void assertCollectionContainsExactly(String documentAsJsonObject)
514516
}
515517

516518
@Entity
517-
@Table(name = "items")
519+
@Table(name = COLLECTION_NAME)
518520
static class ItemWithNestedValues {
519521
@Id
520522
EmbeddableIntegrationTests.Single flattenedId;
@@ -594,7 +596,7 @@ record Plural(
594596
ObjectId objectId) {}
595597

596598
@Entity
597-
@Table(name = "items")
599+
@Table(name = COLLECTION_NAME)
598600
static class ItemWithNestedValueHavingArraysAndCollections {
599601
@Id
600602
int id;
@@ -761,22 +763,22 @@ void testNoPersistentAttributes() {
761763
}
762764

763765
@Entity
764-
@Table(name = "items")
766+
@Table(name = COLLECTION_NAME)
765767
static class ItemWithSingleAsId {
766768
@Id
767769
Single id;
768770
}
769771

770772
@Entity
771-
@Table(name = "items")
773+
@Table(name = COLLECTION_NAME)
772774
record ItemWithNestedValueHavingNonInsertable(@Id int id, PairHavingNonInsertable nested) {}
773775

774776
@Embeddable
775777
@Struct(name = "PairHavingNonInsertable")
776778
record PairHavingNonInsertable(@Column(insertable = false) int a, int b) {}
777779

778780
@Entity
779-
@Table(name = "items")
781+
@Table(name = COLLECTION_NAME)
780782
record ItemWithNestedValueHavingNonUpdatable(@Id int id, PairHavingNonUpdatable nested) {}
781783

782784
@Embeddable
@@ -796,7 +798,7 @@ static class PairHavingNonUpdatable {
796798
}
797799

798800
@Entity
799-
@Table(name = "items")
801+
@Table(name = COLLECTION_NAME)
800802
static class ItemWithNestedValueHavingAllNonInsertable {
801803
@Id
802804
int id;
@@ -809,7 +811,7 @@ static class ItemWithNestedValueHavingAllNonInsertable {
809811
record PairAllNonInsertable(@Column(insertable = false) int a, @Column(insertable = false) int b) {}
810812

811813
@Entity
812-
@Table(name = "items")
814+
@Table(name = COLLECTION_NAME)
813815
static class ItemWithPolymorphicPersistentAttribute {
814816
@Id
815817
int id;
@@ -843,7 +845,7 @@ static class Concrete extends Polymorphic {
843845
}
844846

845847
@Entity
846-
@Table(name = "items")
848+
@Table(name = COLLECTION_NAME)
847849
static class ItemWithNestedValueHavingEmbeddable {
848850
@Id
849851
int id;
@@ -861,7 +863,7 @@ static class ItemWithNestedValueHavingEmbeddable {
861863
record SingleHavingEmbeddable(EmbeddableIntegrationTests.Single flattened) {}
862864

863865
@Entity
864-
@Table(name = "items")
866+
@Table(name = COLLECTION_NAME)
865867
static class ItemWithNestedValueHavingNoPersistentAttributes {
866868
@Id
867869
int id;

src/integrationTest/java/com/mongodb/hibernate/id/MongoIdFieldNameIntegrationTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@
4343
})
4444
@ExtendWith(MongoExtension.class)
4545
class MongoIdFieldNameIntegrationTests {
46+
private static final String COLLECTION_NAME = "movies";
4647

47-
@InjectMongoCollection("movies")
48+
@InjectMongoCollection(COLLECTION_NAME)
4849
private static MongoCollection<BsonDocument> mongoCollection;
4950

5051
@Test
@@ -92,30 +93,30 @@ private static void assertCollectionContainsExactly(BsonDocument expectedDoc) {
9293
}
9394

9495
@Entity
95-
@Table(name = "movies")
96+
@Table(name = COLLECTION_NAME)
9697
static class EntityWithoutIdColumnAnnotation {
9798
@Id
9899
int id;
99100
}
100101

101102
@Entity
102-
@Table(name = "movies")
103+
@Table(name = COLLECTION_NAME)
103104
static class EntityWithIdColumnAnnotationWithoutNameElement {
104105
@Id
105106
@Column
106107
int id;
107108
}
108109

109110
@Entity
110-
@Table(name = "movies")
111+
@Table(name = COLLECTION_NAME)
111112
static class EntityWithIdColumnAnnotationWithValidNameElement {
112113
@Id
113114
@Column(name = ID_FIELD_NAME)
114115
int id;
115116
}
116117

117118
@Entity
118-
@Table(name = "movies")
119+
@Table(name = COLLECTION_NAME)
119120
static class EntityWithIdColumnAnnotationWithInvalidNameElement {
120121
@Id
121122
@Column(name = "silentlyReplaced")

src/integrationTest/java/com/mongodb/hibernate/id/ObjectIdAsIdIntegrationTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
})
4949
@ExtendWith(MongoExtension.class)
5050
class ObjectIdAsIdIntegrationTests implements SessionFactoryScopeAware {
51-
@InjectMongoCollection("items")
51+
private static final String COLLECTION_NAME = "items";
52+
53+
@InjectMongoCollection(COLLECTION_NAME)
5254
private static MongoCollection<BsonDocument> mongoCollection;
5355

5456
private SessionFactoryScope sessionFactoryScope;
@@ -106,22 +108,22 @@ void assignedValue() {
106108
}
107109

108110
@Entity
109-
@Table(name = "items")
111+
@Table(name = COLLECTION_NAME)
110112
static class Item {
111113
@Id
112114
ObjectId id;
113115
}
114116

115117
@Entity
116-
@Table(name = "items")
118+
@Table(name = COLLECTION_NAME)
117119
static class ItemGenerated {
118120
@Id
119121
@ObjectIdGenerator
120122
ObjectId id;
121123
}
122124

123125
@Entity
124-
@Table(name = "items")
126+
@Table(name = COLLECTION_NAME)
125127
static class ItemGeneratedWithPropertyAccess {
126128
private ObjectId id;
127129

0 commit comments

Comments
 (0)