You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by garpinc <ga...@yahoo.com> on 2012/08/28 22:28:36 UTC

@javax.persistence.ElementCollection instead of @org.apache.openjpa.persistence.PersistentCollection I get exception

I have a scenario where i'm trying to use standard JPA annotations vs OpenJPA
annotations. In my mapping if I use @javax.persistence.ElementCollection
instead of @org.apache.openjpa.persistence.PersistentCollection  I get
following exception. 

I have config parameter         jpaConf.put("openjpa.jdbc.MappingDefaults",
"org.openanzo.rdf.URI=com.cambridgesemantics.anzo.relationalreplicator.openjpa.plugin.URIValueHandler'");

but it doesn't seem to take effect for the standard
@javax.persistence.ElementCollection

Is this a bug?


org.apache.openjpa.util.MetaDataException: No metadata was found for type
"interface org.openanzo.rdf.URI". The class is not enhanced.
	at
org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:403)
	at
org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:384)
	at
org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1832)
	at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1797)
	at
org.apache.openjpa.meta.ValueMetaDataImpl.resolve(ValueMetaDataImpl.java:435)
	at org.apache.openjpa.meta.FieldMetaData.resolve(FieldMetaData.java:1880)
	at
org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1863)
	at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1797)
	at
org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:822)
	at
org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:719)
	at
org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:643)




--
View this message in context: http://openjpa.208410.n2.nabble.com/javax-persistence-ElementCollection-instead-of-org-apache-openjpa-persistence-PersistentCollection-In-tp7580963.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: @javax.persistence.ElementCollection instead of @org.apache.openjpa.persistence.PersistentCollection I get exception

Posted by garpinc <ga...@yahoo.com>.
JIRA is https://issues.apache.org/jira/browse/OPENJPA-2256



--
View this message in context: http://openjpa.208410.n2.nabble.com/javax-persistence-ElementCollection-instead-of-org-apache-openjpa-persistence-PersistentCollection-In-tp7580963p7581001.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: @javax.persistence.ElementCollection instead of @org.apache.openjpa.persistence.PersistentCollection I get exception

Posted by garpinc <ga...@yahoo.com>.
I created a JIRA and attached a testcase to illustrate the failing conditions
or unexpected behaviour.

please let me know if anyone has any ideas on resolution.



--
View this message in context: http://openjpa.208410.n2.nabble.com/javax-persistence-ElementCollection-instead-of-org-apache-openjpa-persistence-PersistentCollection-In-tp7580963p7581000.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: @javax.persistence.ElementCollection instead of @org.apache.openjpa.persistence.PersistentCollection I get exception

Posted by garpinc <ga...@yahoo.com>.
After further investigation I found that it has nothing to do with the
ElementCollection or PersistentCollection.
The mapping that was working simply was erroneously leaving out the
problematic column.

I fixed the annotation so it's now as follows:
    @javax.persistence.CollectionTable(
        name="Movie_image",
        joinColumns=@javax.persistence.JoinColumn(name="Movie_fk"))
	@javax.persistence.ElementCollection(targetClass=java.lang.String.class)
	@javax.persistence.Lob
	public java.util.Collection<org.openanzo.rdf.URI> getImage() throws
org.openanzo.rdf.jastor.JastorException {

The table is now being created correctly but at runtime I'm getting a
ClassCastException at line 1300 in DBDictionary

                    setClobString(stmnt, idx, (String) val, col);

val is an instance of org.openanzo.rdf.URI which I passed into openjpa
config with:

        jpaConf.put("openjpa.jdbc.MappingDefaults",
"ForeignKeyDeleteAction=restrict,JoinForeignKeyDeleteAction=restrict,FieldStrategies='"
+ Duration.class.getName() + "=" + DurationValueHandler.class.getName() +
"," + URI.class.getName() + "=" + URIValueHandler.class.getName() + "'");

But I can't seem to find where in the code it's supposed to apply that value
URIValueHandler to create val which could then be cast to a String. 

If anyone has any ideas it would be greatly appreciated.



--
View this message in context: http://openjpa.208410.n2.nabble.com/javax-persistence-ElementCollection-instead-of-org-apache-openjpa-persistence-PersistentCollection-In-tp7580963p7580990.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: @javax.persistence.ElementCollection instead of @org.apache.openjpa.persistence.PersistentCollection I get exception

Posted by Kevin Sutter <kw...@gmail.com>.
Okay, thanks for the clarification.  It sounds like you found a problem
with the @ElementCollection processing.  I'd suggest opening a JIRA.  If
you can provide enough data to reproduce the problem (entity definitions,
junits, etc), it would greatly help with the process.  Thanks.

Kevin

On Wed, Aug 29, 2012 at 10:40 AM, garpinc <ga...@yahoo.com> wrote:

> The issue here is that org.openanzo.rdf.URI is not supposed to be enhanced.
> The URIValueHandler is supposed to handle it when it's encountered but this
> doesn't seem to work unless I use the
> org.apache.openjpa.persistence.PersistentCollection collection method.
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/javax-persistence-ElementCollection-instead-of-org-apache-openjpa-persistence-PersistentCollection-In-tp7580963p7580972.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: @javax.persistence.ElementCollection instead of @org.apache.openjpa.persistence.PersistentCollection I get exception

Posted by garpinc <ga...@yahoo.com>.
The issue here is that org.openanzo.rdf.URI is not supposed to be enhanced.
The URIValueHandler is supposed to handle it when it's encountered but this
doesn't seem to work unless I use the
org.apache.openjpa.persistence.PersistentCollection collection method.



--
View this message in context: http://openjpa.208410.n2.nabble.com/javax-persistence-ElementCollection-instead-of-org-apache-openjpa-persistence-PersistentCollection-In-tp7580963p7580972.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: @javax.persistence.ElementCollection instead of @org.apache.openjpa.persistence.PersistentCollection I get exception

Posted by Kevin Sutter <kw...@gmail.com>.
Getting an exception that states the class hasn't been enhanced is
different from saying that an annotation doesn't seem to be working.  They
may very well be related, but I would first verify whether the class in
question has been enhanced.  How do you perform the enhancement step?  Have
you tried turning on Trace to see if there was an issue with the
enhancement step?  As each Entity class is loaded, OpenJPA determines
whether the class has been enhanced and whether to allow continued
processing (based on properties in persistence.xml).  The default
processing with OpenJPA 2.0 is not continue processing if the entity
classes haven't been enhanced.

So, I would focus on that aspect first.

In general, the @ElementCollection annotation is supported.  I just queried
the JIRAs and there are a couple of edge-case issues related to this
processing, but for the most part, they seem to be working.  You could also
look at the JUnits for this processing to see if our tests cover your
scenario or not.

Good luck,
Kevin

On Tue, Aug 28, 2012 at 3:28 PM, garpinc <ga...@yahoo.com> wrote:

> I have a scenario where i'm trying to use standard JPA annotations vs
> OpenJPA
> annotations. In my mapping if I use @javax.persistence.ElementCollection
> instead of @org.apache.openjpa.persistence.PersistentCollection  I get
> following exception.
>
> I have config parameter         jpaConf.put("openjpa.jdbc.MappingDefaults",
>
> "org.openanzo.rdf.URI=com.cambridgesemantics.anzo.relationalreplicator.openjpa.plugin.URIValueHandler'");
>
> but it doesn't seem to take effect for the standard
> @javax.persistence.ElementCollection
>
> Is this a bug?
>
>
> org.apache.openjpa.util.MetaDataException: No metadata was found for type
> "interface org.openanzo.rdf.URI". The class is not enhanced.
>         at
>
> org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:403)
>         at
>
> org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:384)
>         at
> org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1832)
>         at
> org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1797)
>         at
>
> org.apache.openjpa.meta.ValueMetaDataImpl.resolve(ValueMetaDataImpl.java:435)
>         at
> org.apache.openjpa.meta.FieldMetaData.resolve(FieldMetaData.java:1880)
>         at
> org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1863)
>         at
> org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1797)
>         at
>
> org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:822)
>         at
>
> org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:719)
>         at
>
> org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:643)
>
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/javax-persistence-ElementCollection-instead-of-org-apache-openjpa-persistence-PersistentCollection-In-tp7580963.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>