-
Notifications
You must be signed in to change notification settings - Fork 35
attempt to respecify dataSource #1303
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 all commits
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 |
|---|---|---|
|
|
@@ -66,22 +66,21 @@ | |
| @Target(ElementType.TYPE) | ||
| public @interface Repository { | ||
| /** | ||
| * Value for the {@link Repository#provider()} attribute that allows the use | ||
| * of any available Jakarta Data provider that supports the type of entity | ||
| * annotation that is present on the repository's entity class. | ||
| * Value for the {@link #provider()} attribute that allows the use of | ||
| * any available Jakarta Data provider that supports the type of entity | ||
| * annotation that is present on the repository's entity classes. | ||
| */ | ||
| String ANY_PROVIDER = ""; | ||
|
|
||
| /** | ||
| * <p>Value for the {@link Repository#dataStore()} attribute that indicates | ||
| * to use | ||
| * <p>Value for the {@link #dataStore()} attribute that indicates use of | ||
| * a default data store.</p> | ||
| * | ||
| * <p>When running in a Jakarta EE profile or platform and the entity | ||
| * annotations | ||
| * indicate a relational database, the default data store is the Jakarta EE | ||
| * default data source, {@code java:comp/DefaultDataSource}. Otherwise, the | ||
| * default data store is determined by the Jakarta Data provider.</p> | ||
| * <p>In a Jakarta EE profile or platform environment, if the repository | ||
| * requires a {@code javax.sql.DataSource}, the default data store is the | ||
| * Jakarta EE default data source with name | ||
| * {@code java:comp/DefaultDataSource}. Otherwise, the default data store | ||
| * is determined by the Jakarta Data provider.</p> | ||
| * | ||
| * <p>The default data store might require additional vendor-specific | ||
| * configuration, depending on the vendor.</p> | ||
|
|
@@ -100,14 +99,23 @@ | |
| * Interoperability with Jakarta Config is reserved for future versions | ||
| * of Jakarta Data. | ||
| * </li> | ||
| * <li>If running in a Jakarta EE profile or platform and the entity annotations | ||
| * indicate a relational database and the value begins with {@code java:} and | ||
| * matches the name of a {@code jakarta.annotation.sql.DataSourceDefinition}, | ||
| * the JNDI name of a data source, or a resource reference to a data source, | ||
| * then the corresponding {@code javax.sql.DataSource} is used as the data store. | ||
| * If the same conditions are met but the value matches a persistence unit | ||
| * reference, then the corresponding {@code jakarta.persistence.PersistenceUnit} | ||
| * is used as the data store. | ||
| * <li>In a Jakarta EE profile or platform environment, if the repository | ||
| * implementation requires a {@code javax.sql.DataSource}, and if the | ||
| * value begins with {@code java:} and matches the name of a | ||
| * {@code jakarta.annotation.sql.DataSourceDefinition}, the JNDI name of | ||
| * a {@code DataSource}, or a resource reference to a {@code DataSource}, | ||
| * then the corresponding {@code DataSource} obtained from JNDI is used. | ||
| * </li> | ||
| * <li>In a Jakarta EE profile or platform environment, if the repository | ||
| * implementation requires a Jakarta Persistence | ||
| * {@code jakarta.persistence.EntityManagerFactory} and if the value does | ||
| * not begin with {@code java:} and matches the name of a persistence unit, | ||
| * then the container-managed {@code EntityManagerFactory} for that | ||
| * persistence unit is used, obtained as if it had been injected using the | ||
| * {@code PersistenceUnit} annotation. Or, if the value does begin with | ||
| * {@code java:} and matches the name of a persistence unit reference, | ||
| * then the corresponding {@code EntityManagerFactory} obtained from JNDI | ||
| * is used. | ||
|
Member
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 remembered why I didn't write this with the PersistenceUnit name in the first place. The closest I see is Persistence.createEntityManagerFactory(persistenceUnitName), but that is only for Java SE and also not container managed. It's also possible that there is something in Jakarta Persistence that I am overlooking. I would also be fine with including some language for Java SE usage here.
Member
Author
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.
Member
Author
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 mean, the Javadoc is super-confusing: /**
* (Optional) The name of the persistence unit as defined
* in the {@code persistence.xml} file. If specified, the
* persistence unit for the entity manager factory that is
* accessible in JNDI must have the same name.
*/I don't know what that second sentence means. But I'm basing my assertion on the first sentence:
Member
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.
Right, but we have written the Data spec not to require a compile time step that generates code. I think we would need an equivalent to Persistence.createEntityManagerFactory(persistenceUnitName) for Jakarta EE usage to ensure it is always implementable. 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.
+1 |
||
| * </li> | ||
| * <li>Otherwise, the value serves as an identifier linking to vendor-specific | ||
| * configuration for the Jakarta Data provider to interpret in a vendor-specific | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.