You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by MarWestermann <Ma...@gmx.de> on 2008/10/07 23:42:34 UTC

Exception in using: @OneToMany with mappedBy

Hi,

I have a question and I can't find the answer.
geronimo: 2.1.3
Java: 1.5.07 SE

I have some entities, where all the annotations are defined before the
getter-method. Some of the entities have a one-to-many relationship. But
when I use the mappedBy option, I get the following exception:

<openjpa-1.0.3-r420667:677674 nonfatal user error>
org.apache.openjpa.util.UserException: Type
"org.intersales.qsactive.helpdesk.ebeans.Supportcase" attempts to use both
field and property access. Only one access method is permitted.

Here comes an example:
First the class wich throws the exception:

@Entity
@Table(name="supportcase")
public class Supportcase implements Serializable {

private int key;
private Collection<Customer>;
...
@Id
public int getKey() ...

@OneToMany(mappedBy="supportcase")
public Collection<Customer> getCustomer()...
}

now the Customer-Class
@Entity
@Table(name=customer)
public class Customer implements Serializable {

private int key;
private Supportcase supportcase;

@Id
public int getKey()...

@ManyToOne
public Supportcase getSupportCase()...


I think the problem is, that I use a field-access due to the mappedBy-Option
while the other settings are all made on the getter-methods. When I delete
the mappedBy-keywords, I don't get any exceptions (but for every relation
there is a mapping-table created)

Any advices?

Thanks Marco
-- 
View this message in context: http://www.nabble.com/Exception-in-using%3A-%40OneToMany-with-mappedBy-tp19867956s134p19867956.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Exception in using: @OneToMany with mappedBy

Posted by "Jay D. McHugh" <ja...@gmail.com>.
Marco,

Any luck?

Jay

Jay D. McHugh wrote:
> Marco,
> 
> Sorry that it took so long for anyone to send you a response.
> 
> Here is something to try.
> 
> Add an annotation to your entity classes of:
> 
> @XmlAccessorType(XmlAccessType.PROPERTY)
> 
> I think that OpenJPA has field access set by default.
> 
> Or, if you want to use field access instead, you can explicitly annotate
> your classes with:
> 
> @XmlAccessorType(XmlAccessType.FIELD)
> 
> Hope that helps,
> 
> 
> Jay
> 
> MarWestermann wrote:
>> Hi,
>>
>> nobody an idea? I cannot find anything for this.
>>
>> regards Marco

Re: Exception in using: @OneToMany with mappedBy

Posted by "Jay D. McHugh" <ja...@gmail.com>.
Marco,

Sorry that it took so long for anyone to send you a response.

Here is something to try.

Add an annotation to your entity classes of:

@XmlAccessorType(XmlAccessType.PROPERTY)

I think that OpenJPA has field access set by default.

Or, if you want to use field access instead, you can explicitly annotate
your classes with:

@XmlAccessorType(XmlAccessType.FIELD)

Hope that helps,


Jay

MarWestermann wrote:
> Hi,
> 
> nobody an idea? I cannot find anything for this.
> 
> regards Marco

Re: Exception in using: @OneToMany with mappedBy

Posted by MarWestermann <Ma...@gmx.de>.
Hi,

nobody an idea? I cannot find anything for this.

regards Marco
-- 
View this message in context: http://www.nabble.com/Exception-in-using%3A-%40OneToMany-with-mappedBy-tp19867956s134p19915942.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.