I have a table named AUTHOR_CATHEGORY with two columns that are FK on table AUTHOR and CATHEGORY respectively, wich both have a PK of type Long.
I have created a bean for this table, that has the following descriptor:
<ejb-name>AuthorCathegory</ejb-name>
authors.AuthorCathegoryHome
authors.AuthorCathegory
<ejb-class>authors.AuthorCathegoryBeanCMP</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>authors.AuthorCathegoryPK</prim-key-class>
False
<cmp-field><field-name>relation</field-name></cmp-field>
<primkey-field>relation</primkey-field>
<env-entry>
<env-entry-name>DataSourceName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>SQLServerBiblio</env-entry-value>
</env-entry>
where relation is the name of the only field in the bean that is also the primary key of type authors.AuthorCathegoryPK and authors.AuthorCathegoryPK is defined as follows:
public class AuthorCathegoryPK implements Serializable {
public Long fkAuthor;
public Long fkCathegory;
public AuthorCathegoryPK() {
}
public AutoriCatautoriPK(Long fkAuthor, Long fkCathegory) {
this.fkAuthor= fkAuthor;
this.fkCathegory= fkCathegory;
}
public boolean equals(Object obj) {
if (this.getClass().equals(obj.getClass())) {
AuthorCathegoryPK that = (AuthorCathegoryPK) obj;
return this.fkAuthor.equals(that.fkAuthor) && this.fkCathegory.equals(that.fkCathegory);
}
return false;
}
public int hashCode() {
return ("" +fkAuthor+ fkCathegory).hashCode();
}
}
Finally in the jaws file I mapped fields and columns as follows:
<ejb-name>AuthorCathegory</ejb-name>
<table-name>AUTHOR_CATHEGORY</table-name>
<create-table>false</create-table>
<cmp-field>
<field-name>relation.fkAuthor</field-name>
<column-name>FK_AUTHOR</column-name>
</cmp-field>
<cmp-field>
<field-name>relation.fkCathegory</field-name>
<column-name>FK_CATHEGORY</column-name>
</cmp-field>
When I call a create on this bean I get an error from the jdbc driver saying:
"Name of column 'relation' is not valid"
What's wrong with my mapping ?
Thanks in advance