You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Mark Struberg (JIRA)" <ji...@apache.org> on 2012/05/17 00:11:06 UTC
[jira] [Created] (OPENJPA-2197) MethodComparator in
AnnotationPersistenceMetaDataParser should also compare parameters
Mark Struberg created OPENJPA-2197:
--------------------------------------
Summary: MethodComparator in AnnotationPersistenceMetaDataParser should also compare parameters
Key: OPENJPA-2197
URL: https://issues.apache.org/jira/browse/OPENJPA-2197
Project: OpenJPA
Issue Type: Bug
Components: kernel
Affects Versions: 2.2.0
Reporter: Mark Struberg
Assignee: Mark Struberg
Fix For: 2.3.0
AnnotationPersistenceMetaDataParser contains a MethodComparator which only compares the class + the method name. Too bad I have (had...) 2 methods with the same name in my EntityListener:
@PreUpdate
public void updateChangeLog(Object entity) { ..
and also
private void updateChangeLog(BaseEntity he, ChangeLogEntry cle)
which is a private helper method.
Due to the bug in MethodComparator, my @PreUpdate sometimes didn't get detected.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OPENJPA-2197) MethodComparator in
AnnotationPersistenceMetaDataParser should also compare parameters
Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13277618#comment-13277618 ]
Mark Struberg commented on OPENJPA-2197:
----------------------------------------
We currently use the Method#hashCode in the MethodComparator. But this is really ugly, as it's defined as :
/**
* Returns a hashcode for this <code>Method</code>. The hashcode is computed
* as the exclusive-or of the hashcodes for the underlying
* method's declaring class name and the method's name.
*/
Please note that Method#hashCode does *NOT* cover any method parameters!
As we do already equals on class and the method name, this doesn't bring any benefit.
> MethodComparator in AnnotationPersistenceMetaDataParser should also compare parameters
> --------------------------------------------------------------------------------------
>
> Key: OPENJPA-2197
> URL: https://issues.apache.org/jira/browse/OPENJPA-2197
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.2.0
> Reporter: Mark Struberg
> Assignee: Mark Struberg
> Fix For: 2.3.0
>
> Attachments: OPENJPA-2197_test.patch
>
>
> AnnotationPersistenceMetaDataParser contains a MethodComparator which only compares the class + the method name. Too bad I have (had...) 2 methods with the same name in my EntityListener:
> @PreUpdate
> public void updateChangeLog(Object entity) { ..
> and also
> private void updateChangeLog(BaseEntity he, ChangeLogEntry cle)
> which is a private helper method.
> Due to the bug in MethodComparator, my @PreUpdate sometimes didn't get detected.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (OPENJPA-2197) MethodComparator in
AnnotationPersistenceMetaDataParser should also compare parameters
Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Struberg resolved OPENJPA-2197.
------------------------------------
Resolution: Fixed
fixed in r1339509.
> MethodComparator in AnnotationPersistenceMetaDataParser should also compare parameters
> --------------------------------------------------------------------------------------
>
> Key: OPENJPA-2197
> URL: https://issues.apache.org/jira/browse/OPENJPA-2197
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.2.0
> Reporter: Mark Struberg
> Assignee: Mark Struberg
> Fix For: 2.3.0
>
> Attachments: OPENJPA-2197_test.patch
>
>
> AnnotationPersistenceMetaDataParser contains a MethodComparator which only compares the class + the method name. Too bad I have (had...) 2 methods with the same name in my EntityListener:
> @PreUpdate
> public void updateChangeLog(Object entity) { ..
> and also
> private void updateChangeLog(BaseEntity he, ChangeLogEntry cle)
> which is a private helper method.
> Due to the bug in MethodComparator, my @PreUpdate sometimes didn't get detected.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OPENJPA-2197) MethodComparator in
AnnotationPersistenceMetaDataParser should also compare parameters
Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13277855#comment-13277855 ]
Albert Lee commented on OPENJPA-2197:
-------------------------------------
Per spec section "3.5.1 Lifecycle Callback Methods"
Callback methods defined on an entity class or mapped superclass have the following signature:
void <METHOD>()
Callback methods defined on an entity listener class have the following signature:
void <METHOD>(Object)
I am wondering if a simpler solution is to detect this requirement rather than check for method signature.
I.e.
public static Collection<LifecycleCallbacks>[] parseCallbackMethods
(Class<?> cls, Collection<LifecycleCallbacks>[] callbacks, boolean sups,
boolean listener, MetaDataRepository repos) {
.........
if (Modifier.isStatic(mods) || Modifier.isFinal(mods) ||
Object.class.equals(m.getDeclaringClass()))
continue;
// ******* addition logic to filter out invalid listeners
if( m.getParameterTypes().length != (listener?0:1) || m.getReturnType() != Void.class )
continue;
// *******
key = new MethodKey(m);
if (!seen.contains(key)) {
methods.add(m);
seen.add(key);
}
}
> MethodComparator in AnnotationPersistenceMetaDataParser should also compare parameters
> --------------------------------------------------------------------------------------
>
> Key: OPENJPA-2197
> URL: https://issues.apache.org/jira/browse/OPENJPA-2197
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.2.0
> Reporter: Mark Struberg
> Assignee: Mark Struberg
> Fix For: 2.3.0
>
> Attachments: OPENJPA-2197_test.patch
>
>
> AnnotationPersistenceMetaDataParser contains a MethodComparator which only compares the class + the method name. Too bad I have (had...) 2 methods with the same name in my EntityListener:
> @PreUpdate
> public void updateChangeLog(Object entity) { ..
> and also
> private void updateChangeLog(BaseEntity he, ChangeLogEntry cle)
> which is a private helper method.
> Due to the bug in MethodComparator, my @PreUpdate sometimes didn't get detected.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OPENJPA-2197) MethodComparator in
AnnotationPersistenceMetaDataParser should also compare parameters
Posted by "Albert Lee (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278940#comment-13278940 ]
Albert Lee commented on OPENJPA-2197:
-------------------------------------
Ignore my suggestion! The logic also handles more than the JPA spec required callbacks, which caused some test failures.
> MethodComparator in AnnotationPersistenceMetaDataParser should also compare parameters
> --------------------------------------------------------------------------------------
>
> Key: OPENJPA-2197
> URL: https://issues.apache.org/jira/browse/OPENJPA-2197
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.2.0
> Reporter: Mark Struberg
> Assignee: Mark Struberg
> Fix For: 2.3.0
>
> Attachments: OPENJPA-2197_test.patch
>
>
> AnnotationPersistenceMetaDataParser contains a MethodComparator which only compares the class + the method name. Too bad I have (had...) 2 methods with the same name in my EntityListener:
> @PreUpdate
> public void updateChangeLog(Object entity) { ..
> and also
> private void updateChangeLog(BaseEntity he, ChangeLogEntry cle)
> which is a private helper method.
> Due to the bug in MethodComparator, my @PreUpdate sometimes didn't get detected.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OPENJPA-2197) MethodComparator in
AnnotationPersistenceMetaDataParser should also compare parameters
Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278979#comment-13278979 ]
Mark Struberg commented on OPENJPA-2197:
----------------------------------------
Yes I feared that. I just saw some old stuff I know form kodo, so most probably either JDO or homegrown stuff ;)
> MethodComparator in AnnotationPersistenceMetaDataParser should also compare parameters
> --------------------------------------------------------------------------------------
>
> Key: OPENJPA-2197
> URL: https://issues.apache.org/jira/browse/OPENJPA-2197
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.2.0
> Reporter: Mark Struberg
> Assignee: Mark Struberg
> Fix For: 2.3.0
>
> Attachments: OPENJPA-2197_test.patch
>
>
> AnnotationPersistenceMetaDataParser contains a MethodComparator which only compares the class + the method name. Too bad I have (had...) 2 methods with the same name in my EntityListener:
> @PreUpdate
> public void updateChangeLog(Object entity) { ..
> and also
> private void updateChangeLog(BaseEntity he, ChangeLogEntry cle)
> which is a private helper method.
> Due to the bug in MethodComparator, my @PreUpdate sometimes didn't get detected.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (OPENJPA-2197) MethodComparator in
AnnotationPersistenceMetaDataParser should also compare parameters
Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Struberg updated OPENJPA-2197:
-----------------------------------
Attachment: OPENJPA-2197_test.patch
this test shows the problem. I'm working on a fix right now.
> MethodComparator in AnnotationPersistenceMetaDataParser should also compare parameters
> --------------------------------------------------------------------------------------
>
> Key: OPENJPA-2197
> URL: https://issues.apache.org/jira/browse/OPENJPA-2197
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.2.0
> Reporter: Mark Struberg
> Assignee: Mark Struberg
> Fix For: 2.3.0
>
> Attachments: OPENJPA-2197_test.patch
>
>
> AnnotationPersistenceMetaDataParser contains a MethodComparator which only compares the class + the method name. Too bad I have (had...) 2 methods with the same name in my EntityListener:
> @PreUpdate
> public void updateChangeLog(Object entity) { ..
> and also
> private void updateChangeLog(BaseEntity he, ChangeLogEntry cle)
> which is a private helper method.
> Due to the bug in MethodComparator, my @PreUpdate sometimes didn't get detected.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (OPENJPA-2197) MethodComparator in
AnnotationPersistenceMetaDataParser should also compare parameters
Posted by "Mark Struberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-2197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278170#comment-13278170 ]
Mark Struberg commented on OPENJPA-2197:
----------------------------------------
We should check this in any case. I assumed that this will be checked already. Can you quickly change the test and verify if it fails with a message if you try to apply a lifecycle callback on another method?
I went for fixing the Comparator as I didn't like to change the whole logic of this part. Of course, if there are other open tasks in this area, then we might think about doing a clean rework...
> MethodComparator in AnnotationPersistenceMetaDataParser should also compare parameters
> --------------------------------------------------------------------------------------
>
> Key: OPENJPA-2197
> URL: https://issues.apache.org/jira/browse/OPENJPA-2197
> Project: OpenJPA
> Issue Type: Bug
> Components: kernel
> Affects Versions: 2.2.0
> Reporter: Mark Struberg
> Assignee: Mark Struberg
> Fix For: 2.3.0
>
> Attachments: OPENJPA-2197_test.patch
>
>
> AnnotationPersistenceMetaDataParser contains a MethodComparator which only compares the class + the method name. Too bad I have (had...) 2 methods with the same name in my EntityListener:
> @PreUpdate
> public void updateChangeLog(Object entity) { ..
> and also
> private void updateChangeLog(BaseEntity he, ChangeLogEntry cle)
> which is a private helper method.
> Due to the bug in MethodComparator, my @PreUpdate sometimes didn't get detected.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira