|
31 | 31 | import com.mongodb.hibernate.internal.type.ObjectIdJavaType; |
32 | 32 | import com.mongodb.hibernate.internal.type.ObjectIdJdbcType; |
33 | 33 | import com.mongodb.hibernate.jdbc.MongoConnectionProvider; |
| 34 | +import java.math.BigDecimal; |
34 | 35 | import java.sql.PreparedStatement; |
35 | 36 | import java.sql.ResultSet; |
36 | 37 | import java.sql.Timestamp; |
37 | 38 | import java.time.Instant; |
38 | 39 | import java.util.Calendar; |
39 | 40 | import org.hibernate.JDBCException; |
| 41 | +import java.util.Collection; |
| 42 | +import org.bson.types.ObjectId; |
| 43 | +import org.hibernate.annotations.Struct; |
40 | 44 | import org.hibernate.boot.model.FunctionContributions; |
41 | 45 | import org.hibernate.boot.model.TypeContributions; |
42 | 46 | import org.hibernate.cfg.AvailableSettings; |
|
57 | 61 | import org.hibernate.sql.model.internal.OptionalTableUpdate; |
58 | 62 | import org.hibernate.sql.model.jdbc.OptionalTableUpdateOperation; |
59 | 63 | import org.hibernate.type.SqlTypes; |
| 64 | +import org.hibernate.type.WrapperArrayHandling; |
60 | 65 | import org.hibernate.type.descriptor.jdbc.TimestampUtcAsInstantJdbcType; |
61 | 66 | import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl; |
62 | 67 | import org.jspecify.annotations.Nullable; |
|
70 | 75 | * creating a JDBC adaptor on top of <a href="https://www.mongodb.com/docs/drivers/java/sync/current/">MongoDB Java |
71 | 76 | * Driver</a>. |
72 | 77 | * |
| 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 | + * |
73 | 151 | * <p>For the documentation on the supported <a |
74 | 152 | * href="https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#hql-exp-functions">HQL |
75 | 153 | * functions</a> see {@link #initializeFunctionRegistry(FunctionContributions)}. |
@@ -250,7 +328,7 @@ public boolean supportsStandardArrays() { |
250 | 328 | * </li> |
251 | 329 | * <li> |
252 | 330 | * 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 |
254 | 332 | * {@linkplain org.hibernate.query.SelectionQuery#setParameter(String, Object) query parameter}. |
255 | 333 | * </li> |
256 | 334 | * </ul> |
|
0 commit comments