More static property names
The spec defines a large number of configuration properties, which are spread out over three different sections. In #862 I'm trying to resolve some inconsistencies between these lists. One issue that arises is what to do about these properties:
jakarta.persistence.provider
jakarta.persistence.qualifiers
jakarta.persistence.scope
jakarta.persistence.transactionType
jakarta.persistence.jtaDataSource
jakarta.persistence.nonJtaDataSource
jakarta.persistence.sharedCache.mode
jakarta.persistence.validation.mode
These are overrides for XML elements in persistence.xml, and so:
- they don't make sense as properties in
persistence.xml, nor, by extension, for use withPersistenceConfiguration, but, instead - they're used with
Persistence.createEntityManager()when you have a pre-writtenpersistence.xmlfile.
And so when we added the static property names to PersistenceConfiguration in 3.2, I left them off, with the sole exception (which I'm not inclined to regret) of jakarta.persistence.sharedCache.mode, because setting that property to NONE is just sooo useful that it seemed a mistake to leave it off.
However, thinking all this stuff through more carefully:
- I now realize that being able to override the
jta-datasourceandnon-jta-datasourceelements is at least as useful; - one can even make a case that
jakarta.persistence.transactionTypeis useful in tests; and - I guess maybe if you have a persistence unit archive that's used in multiple different application, being able to specify
jakarta.persistence.qualifiersandjakarta.persistence.scopeexternally is actually pretty nice.
So I think it makes sense to declare these properties as constants somewhere. But where?
- They don't really belong on
PersistenceConfigurationbecause they're not intended for use with that class. - The most sensible place to put them is on
Persistenceitself. But then it seems strange to have only these ones onPersistence. What should I do, copy all of them there, and use them by reference inPersistenceConfiguration?
I now kinda regret the decision to have put them on PersistenceConfiguration instead of Persistence in the first place. It just seemed natural at the time that properties which had to do with "configuring persistence" would go on a class called PersistenceConfiguration. Perhaps the best idea here is to just double down on that arguably bad decision.