openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason Hanna" <jason.m.hanna.at.coincid...@gmail.com>
Subject Proper Use of @ReadOnly Annotation
Date Fri, 19 Dec 2008 17:22:27 GMT
Hi All,

I'm having some trouble getting the @ReadOnly annotation working on my project.

It appears from the javadoc there is an attribute called 'value' of
type UpdateAction. In order to compile my code it seems I need an
annotation like this (which seems unusual):

        @Column(name="create_ts")
	@ReadOnly(value=UpdateAction.valueOf("IGNORE"))
	public java.util.Date getInsertDatetime() {
            ...
        }

Not sure why value requires a type of UpdateAction - it seems an odd
way. This is the only way I've been able to compile with this
annotation, however (using Sun JDK 1.6.0_11).

Unfortunately when my build tool attempts to enhance this classe I'm
now getting the following exception:

     [java] Exception in thread "main"
java.lang.annotation.AnnotationTypeMismatchException: Incorrectly
typed data found for annotation element public abstract
org.apache.openjpa.persistence.UpdateAction
org.apache.openjpa.persistence.ReadOnly.value() (Found data of type
Lorg/apache/openjpa/persistence/UpdateAction;.IGNORE)
     [java]     at
sun.reflect.annotation.AnnotationTypeMismatchExceptionProxy.generateException(AnnotationTypeMismatchExceptionProxy.java:38)
     [java]     at
sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:56)
     [java]     at $Proxy7.value(Unknown Source)
     [java]     at
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseReadOnly(AnnotationPersistenceMetaDataParser.java:1160)
     [java]     at
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseMemberAnnotations(AnnotationPersistenceMetaDataParser.java:1120)
     [java]     at
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseClassAnnotations(AnnotationPersistenceMetaDataParser.java:612)
     [java]     at
org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parse(AnnotationPersistenceMetaDataParser.java:352)
     [java]     at
org.apache.openjpa.persistence.PersistenceMetaDataFactory.load(PersistenceMetaDataFactory.java:229)
     [java]     at
org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:474)
     [java]     at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:294)
     [java]     at
org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:248)
     [java]     at
org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4492)
     [java]     at
org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4439)
     [java]     at
org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4409)
     [java]     at
org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:708)
     [java]     at
org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:698)
     [java]     at
org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4404)
     [java]     at
org.apache.openjpa.enhance.PCEnhancer.main(PCEnhancer.java:4395)
     [java] Java Result: 1

What am I doing wrong here? I would think I should be able to use the
annotation like this:

@ReadOnly(value=UpdateAction.IGNORE)

But that's clearly a type mis-match at compile time.

Thanks,
-jmh

PS - An example in the manual or javadocs would be helpful!

Mime
View raw message