-
Notifications
You must be signed in to change notification settings - Fork 13
Add internal docs and do other improvements #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
36b51cd
11a6545
8d47b4d
02cdb67
1fc2c92
2678e97
278b519
f83a1df
94b6169
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,13 +23,22 @@ | |
|
|
||
| import com.mongodb.hibernate.internal.FeatureNotSupportedException; | ||
| import org.hibernate.annotations.DynamicInsert; | ||
| import org.hibernate.boot.Metadata; | ||
| import org.hibernate.boot.MetadataSources; | ||
| import org.hibernate.boot.ResourceStreamLocator; | ||
| import org.hibernate.boot.registry.BootstrapServiceRegistry; | ||
| import org.hibernate.boot.spi.AdditionalMappingContributions; | ||
| import org.hibernate.boot.spi.AdditionalMappingContributor; | ||
| import org.hibernate.boot.spi.InFlightMetadataCollector; | ||
| import org.hibernate.boot.spi.MetadataBuildingContext; | ||
| import org.hibernate.mapping.PersistentClass; | ||
|
|
||
| /** | ||
| * The instance methods like {@link #getContributorName()}, {@link #contribute(AdditionalMappingContributions, | ||
| * InFlightMetadataCollector, ResourceStreamLocator, MetadataBuildingContext)} are called multiple times if multiple | ||
| * {@link Metadata} instances are {@linkplain MetadataSources#buildMetadata() built} using the same | ||
| * {@link BootstrapServiceRegistry}. | ||
|
||
| */ | ||
| public final class MongoAdditionalMappingContributor implements AdditionalMappingContributor { | ||
|
|
||
| public MongoAdditionalMappingContributor() {} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,9 @@ | |
| import java.io.Serial; | ||
| import java.util.Map; | ||
| import org.hibernate.HibernateException; | ||
| import org.hibernate.boot.registry.BootstrapServiceRegistry; | ||
| import org.hibernate.boot.registry.StandardServiceInitiator; | ||
| import org.hibernate.boot.registry.StandardServiceRegistry; | ||
| import org.hibernate.boot.registry.StandardServiceRegistryBuilder; | ||
| import org.hibernate.service.Service; | ||
| import org.hibernate.service.UnknownServiceException; | ||
|
|
@@ -49,6 +51,11 @@ public MongoConfiguration getConfiguration() { | |
| return config; | ||
| } | ||
|
|
||
| /** | ||
| * The instance methods like {@link #contribute(StandardServiceRegistryBuilder)} are called multiple times if | ||
| * multiple {@link StandardServiceRegistry} instances are {@linkplain StandardServiceRegistryBuilder#build() built} | ||
| * using the same {@link BootstrapServiceRegistry}. | ||
| */ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, I failed to see why multiple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that matters. What does matter is that doing so is possible with the API of Hibernate ORM, and it is not forbidden by the API documentation, so we must take that into account when we are extending Hibernate ORM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that is why I got confused. Yeah, it is not forbidden, but why we need to cover it? I never know of such scenario that we need to create multiple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So from my understanding, Hibernate's If multiple During runtime, one From my understanding, one and only one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above comment also explains why I got puzzled by your previous PR; but you modified it to make it aligned with reality so I approved that. |
||
| public static final class ServiceContributor implements org.hibernate.service.spi.ServiceContributor { | ||
| public ServiceContributor() {} | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,7 +26,14 @@ | |||||
| import org.hibernate.sql.model.ast.TableMutation; | ||||||
| import org.hibernate.sql.model.jdbc.JdbcMutationOperation; | ||||||
|
|
||||||
| /** | ||||||
| * Tread-safe. | ||||||
|
||||||
| * Tread-safe. | |
| * Thread-safe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way we work around the issue fixed in hibernate/hibernate-orm#9900, because we are not getting that fix in Hibernate ORM 6.x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your raising the issue and it is a quick fix. On the other hand, it seems trivial to me for we only avoid one unnecessary duplicated object creation (which usually is not a big deal for the creation is not costly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other id generator defect is more important and hard to fix from Hibernate side. I created a PR at hibernate/hibernate-orm#9965. Let us see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR @NathanQingyangXu mentioned was superseded with hibernate/hibernate-orm#9969, and the fix was released in 6.6.14.