Skip to content

Commit 8414f45

Browse files
committed
Merge branch 'main' into HIBERNATE-95
# Conflicts: # src/main/java/com/mongodb/hibernate/dialect/MongoDialect.java
2 parents 1a22030 + 2e7cae3 commit 8414f45

File tree

1 file changed

+79
-1
lines changed

1 file changed

+79
-1
lines changed

src/main/java/com/mongodb/hibernate/dialect/MongoDialect.java

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@
3131
import com.mongodb.hibernate.internal.type.ObjectIdJavaType;
3232
import com.mongodb.hibernate.internal.type.ObjectIdJdbcType;
3333
import com.mongodb.hibernate.jdbc.MongoConnectionProvider;
34+
import java.math.BigDecimal;
3435
import java.sql.PreparedStatement;
3536
import java.sql.ResultSet;
3637
import java.sql.Timestamp;
3738
import java.time.Instant;
3839
import java.util.Calendar;
3940
import org.hibernate.JDBCException;
41+
import java.util.Collection;
42+
import org.bson.types.ObjectId;
43+
import org.hibernate.annotations.Struct;
4044
import org.hibernate.boot.model.FunctionContributions;
4145
import org.hibernate.boot.model.TypeContributions;
4246
import org.hibernate.cfg.AvailableSettings;
@@ -57,6 +61,7 @@
5761
import org.hibernate.sql.model.internal.OptionalTableUpdate;
5862
import org.hibernate.sql.model.jdbc.OptionalTableUpdateOperation;
5963
import org.hibernate.type.SqlTypes;
64+
import org.hibernate.type.WrapperArrayHandling;
6065
import org.hibernate.type.descriptor.jdbc.TimestampUtcAsInstantJdbcType;
6166
import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl;
6267
import org.jspecify.annotations.Nullable;
@@ -70,6 +75,79 @@
7075
* creating a JDBC adaptor on top of <a href="https://www.mongodb.com/docs/drivers/java/sync/current/">MongoDB Java
7176
* Driver</a>.
7277
*
78+
* <table>
79+
* <caption>Default type mapping</caption>
80+
* <thead>
81+
* <tr>
82+
* <th>Java type</th>
83+
* <th><a href="https://www.mongodb.com/docs/manual/reference/bson-types/">BSON type</a></th>
84+
* </tr>
85+
* </thead>
86+
* <tbody>
87+
* <tr>
88+
* <td><a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-4.html#jls-4.1">null type</a></td>
89+
* <td>BSON {@code Null}</td>
90+
* </tr>
91+
* <tr>
92+
* <td>{@code byte[]}</td>
93+
* <td>BSON {@code Binary data} with subtype 0</td>
94+
* </tr>
95+
* <tr>
96+
* <td>{@code char}, {@link Character}, {@link String}, {@code char[]}</td>
97+
* <td>BSON {@code String}</td>
98+
* </tr>
99+
* <tr>
100+
* <td>{@code int}, {@link Integer}</td>
101+
* <td>BSON {@code 32-bit integer}</td>
102+
* </tr>
103+
* <tr>
104+
* <td>{@code long}, {@link Long}</td>
105+
* <td>BSON {@code 64-bit integer}</td>
106+
* </tr>
107+
* <tr>
108+
* <td>{@code double}, {@link Double}</td>
109+
* <td>BSON {@code Double}</td>
110+
* </tr>
111+
* <tr>
112+
* <td>{@code boolean}, {@link Boolean}</td>
113+
* <td>BSON {@code Boolean}</td>
114+
* </tr>
115+
* <tr>
116+
* <td>{@link BigDecimal}</td>
117+
* <td>BSON {@code Decimal128}</td>
118+
* </tr>
119+
* <tr>
120+
* <td>{@link ObjectId}</td>
121+
* <td>BSON {@code ObjectId}</td>
122+
* </tr>
123+
* <tr>
124+
* <td>{@link Instant}</td>
125+
* <td>BSON {@code Date}</td>
126+
* </tr>
127+
* <tr>
128+
* <td>{@link Struct} <a href="https://docs.hibernate.org/orm/6.6/userguide/html_single/#embeddable-mapping-aggregate">aggregate embeddable</a></td>
129+
* <td>
130+
* BSON {@code Object}
131+
*
132+
* <p>Field values are mapped as per this table.
133+
* </td>
134+
* </tr>
135+
* <tr>
136+
* <td>
137+
* array, {@link Collection} (or a subtype supported by Hibernate ORM),
138+
* except for {@code byte[]}, {@code char[]}
139+
*
140+
* <p>Note that {@link Character}{@code []} requires setting {@value AvailableSettings#WRAPPER_ARRAY_HANDLING} to {@link WrapperArrayHandling#ALLOW}.
141+
* </td>
142+
* <td>
143+
* BSON {@code Array}
144+
*
145+
* <p>Array elements are mapped as per this table.
146+
* </td>
147+
* </tr>
148+
* </tbody>
149+
* </table>
150+
*
73151
* <p>For the documentation on the supported <a
74152
* href="https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#hql-exp-functions">HQL
75153
* functions</a> see {@link #initializeFunctionRegistry(FunctionContributions)}.
@@ -250,7 +328,7 @@ public boolean supportsStandardArrays() {
250328
* </li>
251329
* <li>
252330
* The second argument must not be an HQL path expression.
253-
* Also, it must be an array and not be a {@link java.util.Collection} when specified as
331+
* Also, it must be an array and not be a {@link Collection} when specified as
254332
* {@linkplain org.hibernate.query.SelectionQuery#setParameter(String, Object) query parameter}.
255333
* </li>
256334
* </ul>

0 commit comments

Comments
 (0)