Skip to content
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

[JDO-709] Enable Element.TYPE for @Convert #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Dieken
Copy link

@Dieken Dieken commented Oct 26, 2022

This reverts commit bddffab to be consistent with its javadoc.

With this capability, we can avoid as much configuration file as possible, it's very convenient to mark default attribute converter for a type with Java annotation.

Reference: https://issues.apache.org/jira/browse/JDO-709?focusedCommentId=17619585&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17619585

This reverts commit bddffab to be consistent with its javadoc.

With this capability, we can avoid as much configuration file as possible, it's very convenient
to mark default attribute converter for a type with Java annotation.

Reference: https://issues.apache.org/jira/browse/JDO-709?focusedCommentId=17619585&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17619585
@Dieken
Copy link
Author

Dieken commented Oct 26, 2022

Notify some authors touched this file, please have a look, thanks! @clr-apache @mboapache @tobous

@clr-apache
Copy link
Contributor

clr-apache commented Oct 28, 2022

The original goal for having Element.Type apply to @Convert was to allow a PersistenceCapable class to have all of the field convert annotations in one place at the definition of the class instead of needing the annotation on each field/property. But this requires new properties on @Convert to identify the field plus the converter for each field. We decided that this use case was not really needed.
But a different use, case recently identified by @Dieken is to annotate the field type for a user-defined class that will by default always use the converter regardless of which PersistenceCapable class the field is defined in. This use case requires the Element.Type to be supported by @Convert.
Note that the JPA annotation supports this use case and therefore there should be minimal changes needed to DataNucleus to support JDO in addition to JPA which is already supported. Perhaps @andyjefferson can comment on whether this can be done easily or if it already should work with JDO if the annotation is enabled.
To properly support this use case we should have TCK tests for it. There are already test cases for AttributeConverters which should have a new test added.
One test case should annotate a new user-defined type with @Convert and verify that the converter is used for date between memory and the datastore. Another test case should override the default case and verify that the override conversion is used instead of the conversion defined in the annotation for the class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants