Quite by accident I worked out what the issue is.I messed up another Entity
class (my single greatest skill) and worked though it to find out that on my
join I was putting the @OneToMany(cascade={CascadeType.ALL}) annotation on
the getter method and had exactly the same issue. Then I realized that the
issue occurs because I need to put the annotation on the private data member
instead and then it works ok.The exception thrown doesn't make a lot of sense because as per my email below, the exception message states that I am mixing property and field access but lists nothing in the field access list and everything in the property access methods. So I would have thought that putting the annotation on the getter would have put that method into the exception message's list of field accesses. Anyway it'd be nice if it could do this for newbies like me J Anyway so now I can resolve this issue I'll look into what you pointed out Mike.my @OneToMany annotation is on the wrong Entity. Thanks for your efforts and advice. Chris From: Michael Dick [mailto:[email protected]] Sent: Sunday, 12 July 2009 8:24 AM To: [email protected]; [email protected] Subject: Re: Exception when doing join Hi, I haven't been able to reproduce the problem you describe, could you post the entire entity (or a subset that illustrates the problem)? BTW the JoinColumn is on the wrong side of the relationship in your example you should see a different exception once you get past the access type problem. Ie : <openjpa-1.2.0-r422266:683325 fatal user error> org.apache.openjpa.persistence.ArgumentException: You have supplied columns for "openjpa.users.cndavies.entities.UserEntity.addresses", but this mapping cannot have columns in this context. at org.apache.openjpa.jdbc.meta.MappingInfo.assertNoSchemaComponents(MappingInf o.java:327) at org.apache.openjpa.jdbc.meta.strats.RelationToManyTableFieldStrategy.map(Rel ationToManyTableFieldStrategy.java:96) <snip> -mike On Sat, Jul 11, 2009 at 9:15 AM, C N Davies <[email protected]> wrote: I've not done this before so maybe I'm missing something basic but I have followed the docs as far as I can see. I have an Entity User, which I want to have multiple addresses so I simply added a I thought were the appropriate annotations and members like so: private Collection <Address> addresses; */ public void setAddresses(Collection <Address> addresses) { this.addresses = addresses; } @OneToMany(cascade={CascadeType.ALL}) @JoinColumn(name="id") public Collection <Address> getAddresses() { return addresses; } As soon as I add the @OneToMany annotation and OpenJPA starts to generate the tables, it throws an exception complaining I am using both field and property access, however the exception lists no members using field access and only 1 using property access so I a not sure why it is telling me I am using both. Here is the stack trace, thanks for any advice!: <openjpa-1.2.0-r422266:683325 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Type "com.trm.core.User" attempts to use both field and property access. Only one access method is permitted. Field access is used on the following fields: []. Property access is used on the following methods: [public java.util.Collection com.trm.core.User.getAddresses()]. org.apache.openjpa.meta.AbstractMetaDataDefaults.populate(AbstractMetaDataDe faults.java:161) org.apache.openjpa.persistence.PersistenceMetaDataDefaults.populate(Persiste nceMetaDataDefaults.java:227) org.apache.openjpa.meta.MetaDataRepository.addMetaData(MetaDataRepository.ja va:794) org.apache.openjpa.meta.MetaDataRepository.addMetaData(MetaDataRepository.ja va:780) org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.getMetaDa ta(AnnotationPersistenceMetaDataParser.java:657) org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseClas sAnnotations(AnnotationPersistenceMetaDataParser.java:480) org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parse(Ann otationPersistenceMetaDataParser.java:352) org.apache.openjpa.persistence.PersistenceMetaDataFactory.load(PersistenceMe taDataFactory.java:229) org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepos itory.java:474) org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.ja va:294) org.apache.openjpa.jdbc.meta.MappingRepository.getMapping(MappingRepository. java:285) org.apache.openjpa.jdbc.meta.MappingTool.getMapping(MappingTool.java:676) org.apache.openjpa.jdbc.meta.MappingTool.buildSchema(MappingTool.java:748) org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:646) org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBro kerFactory.java:153) org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFac tory.java:119) org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFact ory.java:189) org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBroker Factory.java:142) org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager( EntityManagerFactoryImpl.java:192) org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager( EntityManagerFactoryImpl.java:145) org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager( EntityManagerFactoryImpl.java:56) com.trm.jpa.services.EntityService.createEntityManager(EntityService.java:73 ) com.trm.jpa.services.EntityService.<init>(EntityService.java:34) com.trm.beans.backing.CountryListBackingBean.init(CountryListBackingBean.jav a:28) com.trm.beans.backing.CountryListBackingBean.<init>(CountryListBackingBean.j ava:33) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) java.lang.reflect.Constructor.newInstance(Unknown Source) java.lang.Class.newInstance0(Unknown Source) java.lang.Class.newInstance(Unknown Source) com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryIm pl.java:275) com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBea ns(ApplicationAssociate.java:551) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:8 2) javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53) com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver. java:64) org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45) org.apache.el.parser.AstValue.getValue(AstValue.java:86) org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186) org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101 ) javax.faces.component.UIData.getValue(UIData.java:582) org.ajax4jsf.component.UIDataAdaptor.getValue(UIDataAdaptor.java:1624)
