Conversation
e09d7d8 to
14ac8e5
Compare
14ac8e5 to
4984a79
Compare
| /** | ||
| * The schema management action to be performed by generated DDL scripts. | ||
| */ | ||
| SchemaManagementAction schemaManagementScriptsAction() default NONE; |
There was a problem hiding this comment.
Not sure it really makes sense to have this here.
| * schemaManagementDatabaseAction = VALIDATE, | ||
| * properties = { | ||
| * @PersistenceProperty(name="jakarta.persistence.jdbc.batchSize", value="20"), | ||
| * @PersistenceProperty(name="jakarta.persistence.jdbc.fetchSize", value="1000") |
There was a problem hiding this comment.
Like the properties in other @XXXXDefinition, use a list of string that contain the property field/value is ok.
properties = {"abc=xyz", ...}
Optionally, add a propertiesMap as alternative.
propertiesMap = mapOf(...)There was a problem hiding this comment.
@hantsy Well, there's various ways I could answer that question.
First: if we're inventing a minilanguage, why not go all the way and just say properties is a text block and you write:
properties = """
jakarta.persistence.jdbc.batchSize = 20
jakarta.persistence.jdbc.fetchSize = 1000
""";That's even better, no?
Second: to me this question simply proves what I've been trying to say, which is that annotations are simply a pretty uncomfortable place to stick configuration properties! Even you, who were the one who wanted this feature, don't really feel comfortable with @PersistenceProperty (which has been there since JPA 1.0, from back when we didn't really know how to write Java).
Third: well, there's an actual good answer to your question and it's my fault for posting a bad code example. The answer is that you can write:
@PersistenceProperty(name=PersistenceConfiguration.JDBC_FETCH_SIZE, value="20")I will update the code sample to reflect that usage.
There was a problem hiding this comment.
Anyway, please keep in mind that the real essence of this proposal is that your config properties are more likely to be specified in the .properties file, not in the Java code. The idea here is to decouple:
- persistence unit declaration, from
- config properties.
There was a problem hiding this comment.
Oh and:
propertiesMap = mapOf(...)
You can't have a Map as an annotation member in Java.
| * } | ||
| * ) | ||
| * module org.example.library { ... } | ||
| * } |
There was a problem hiding this comment.
The new PersistenceModule depends on JPMS system?
There was a problem hiding this comment.
According to this proposal, it depends on having a module descriptor, yes.
OndroMih
left a comment
There was a problem hiding this comment.
I added a few questions to specific lines, @gavinking
| persistence classes included in the persistence unit using the `class` | ||
| element of the `persistence.xml` file. See <<a12305>>. | ||
|
|
||
| ==== Persistence Properties Files |
There was a problem hiding this comment.
A question: Where do these properties file reside? For example, I have a WAR with a JAR, which is a JPA module. Do I put the properties file into the JAR, into the WAR or keep it outside and specify it at deployment time?
There was a problem hiding this comment.
According to what is specified here, it goes in the META-INF directory of the JAR (i.e. of the persistence unit package).
Obviously I'm anticipating a future where these properties could also be specified in a location external to the persistence unit archive. But that's not in this proposal.
| persistence classes included in the persistence unit using the `class` | ||
| element of the `persistence.xml` file. See <<a12305>>. | ||
|
|
||
| ==== Persistence Properties Files |
There was a problem hiding this comment.
Another question: To use the properties files, do I need to use the new PersistenceModule annotation? Or I can define a properties file also for PUs defined in persistence.xml?
Since the properties file name is tied with PU name, it should also make sense to use it with any PU, not only a PU in a persistence module, right? If yes, I think it makes sense to split this proposal about properties files into a separate PR.
There was a problem hiding this comment.
To use the properties files, do I need to use the new PersistenceModule annotation?
No, it says "a persistence unit", that is, any persistence unit.
Since the properties file name is tied with PU name, it should also make sense to use it with any PU, not only a PU in a persistence module, right?
Yes.
I think it makes sense to split this proposal about properties files into a separate PR.
As it is, it's not really especially useful without the annotation. If you're going to put properties in the META-INF directory, and you already have a persistence.xml there, you might as well just put them in persistence.xml. (Obviously it becomes more useful if they can also be sourced from somewhere else.)
|
Note that if we ever did this, the annotation should also allow specification of the info that is currently allowed in |
| * mapping format, be uniquely named, and be resource-loadable | ||
| * from the application classpath. | ||
| */ | ||
| String[] mappingFileNames() default {}; |
There was a problem hiding this comment.
Following #237 (comment) - how we could add those defaults here? Would we follow with similar annotation for mapping files? Then, would make sense to separate those defaults somehow and use them directly here? Not sure about consequences ...
This change introduces:
moduleas defining a persistence unit (or "persistence archive" in language we were using early on), that is, a package of entities and related code, along with XML mapping files, andpersistence.xml, and.propertiesfile.See #701 (comment).
NOTE: This proposal is on ice until I can get feedback from someone else who is prepared to spend time thinking carefully about what a "persistence unit" or "persistence module" is going to mean in the future. Since I have not been able to gather such feedback yet, this feature is not currently planned for JPA 4.