openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <adam....@cyberspaceroad.org>
Subject many-to-many join table problem
Date Mon, 26 Nov 2007 13:27:33 GMT
Can anyone spot my problem? There must be something simple wrong with my 
approach because I am following the examples in the docs but I'm getting this error:

org.apache.openjpa.persistence.ArgumentException: You have supplied columns for 
"org.permacode.patternrepo.domain.Category.codes<element:class 
org.permacode.patternrepo.domain.Code>", but this mapping cannot have columns in 
this context.

I have tried various permutations to write the mapping but seem to have 
exhausted all avenues. This is the class:

public class Category implements Serializable
{
     private static final long serialVersionUID = -4057308541301713754L;

     private Long id;

     private String title;

     private Collection<Code> codes;

     /** default constructor */
     public Category()
     {
     }
     .... // with constructors, setters and getters


public class Code implements Serializable
{
     private static final long serialVersionUID = -6384628886028362912L;

     private Long id;

     private Collection<Category> categories;

     /** default constructor */
     public Code()
     {
     }

and the entity mapping:

   <entity class="org.permacode.patternrepo.domain.Category">
     <table name="CATEGORY" />
     <attributes>
       <id name="id">
         <column name="ID" />
         <generated-value strategy="TABLE" generator="categoryKeySequence" />
       </id>
       <basic name="title">
         <column name="TITLE" />
       </basic>
       <many-to-many name="codes">
         <order-by></order-by>
         <join-table name="CATEGORY_CODE_LINK">
           <join-column name="CATEGORY_ID" referenced-column-name="ID"/>
           <inverse-join-column name="CODE_ID" referenced-column-name="ID" />
         </join-table>
       </many-to-many>
     </attributes>
   </entity>

the mapping for Code follows exactly the same syntax.

Mime
View raw message