Date
1 - 6 of 6
How to use datanucleus.CurrentUserProvider?
1919wang@...
According to JDO Mapping Guide, to support auditing @CreateUser, we could define an implementation of the DataNucleus interface CurrentUserProvider, and specify it on PMF creation using the property datanucleus.CurrentUserProvider.
I have a com.alpha.MyUserProvider implements CurrentUserProvider, and tried to set the property like below: PersistenceUnitMetaData globalPumd = new PersistenceUnitMetaData(jdoName, transactionType, null);
(CurrentUserProvider)config.getProperty(PropertyNames.PROPERTY_MAPPING_CURRENT_USER_PROVIDER);
|
|
You create an INSTANCE of your CurrentUserProvider, and specify that as the value of "datanucleus.CurrentUserProvider" to the persistence properties.
If you insist on creating a PMF in that way you use the second argument to input OVERRIDING PROPERTIES. |
|
Thanks Andy.
I have several more questions:
|
|
I didnt mention JDOPersistenceManagerFactory.setPersistenceProperties(), no.
PersistenceUnitMetaData is to replicate the file "persistence.xml" content. You cannot specify an Object in a text-based persistence.xml file. Hence PersistenceUnitMetaData doesnt support Object values. |
|
1919wang@...
I got your point on PersistenceUnitMetaData.
You create an INSTANCE of your CurrentUserProvider, and specify that as the value of "datanucleus.CurrentUserProvider" to the persistence properties. |
|
The "persistence properties" are amply defined in the docs. "datanucleus.CurrentUserProvider" is one of them.
As said, you are using PersistenceManagerFactory pmf = new JDOPersistenceManagerFactory(globalPumd, null); and you need to provide any ADDITIONAL persistence properties (such as the one you wanted to specify) via the second argument in that constructor. |
|