Doing this for a course at the university, and the teachers offer no help. The deadline is
starting to approach fast, with all the troubles of outdated tutorials etc.
My current error is of "column not found", as JBoss tries to store the
relationship id (I'm guessing).
The error given is
javax.ejb.CreateException: Could not create entity:java.sql.SQLException: Column not
found: PERSON_EXPERIENCE in statement [INSERT INTO EXPERIENCE (id, area, years,
Person_experience) VALUES (?,?,?,?)]
I have not defined Person_experience in my jbosscmp-jdbc.xml nor my ejb-jar.xml because
when I previously had tried to do so, mapping it to the column person_id, the same error
arose and it tried to insert five values instead of the above four.
My sql table looks like this
create table if not exists experience(
| id VARCHAR(15) PRIMARY KEY,
| area VARCHAR(50),
| years VARCHAR(3),
| Person_experience VARCHAR(15),
| CONSTRAINT Person_experience FOREIGN KEY (Person_experience) REFERENCES person(id)
And yes, the table person does have an id-field.
I've attempted manually inserting random values into my database as a test - seeing
whether it's case sensitive, but it's not.
My primary keys are of their own class
from ejb-jar.xml
<prim-key-class>ejb.entities.ExperiencePK</prim-key-class>
and ofcourse, PersonPK for the person bean.
My PK classes takes int as an id value, and my database as you can see takes varchar. This
has not been a problem when only saving to the Person table (as it in itself does not
contain any relations).
My relationship mappings look like this
ejb-jar.xml:
<ejb-relation>
| <ejb-relation-name>Person - experience</ejb-relation-name>
| <ejb-relationship-role>
| <ejb-relationship-role-name>PersonToExp</ejb-relationship-role-name>
| <multiplicity>One</multiplicity>
| <relationship-role-source>
| <ejb-name>Person</ejb-name>
| </relationship-role-source>
| <cmr-field>
| <cmr-field-name>experience</cmr-field-name>
| <cmr-field-type>java.util.Collection</cmr-field-type>
| </cmr-field>
| </ejb-relationship-role>
| <ejb-relationship-role>
| <ejb-relationship-role-name>ExpToPerson</ejb-relationship-role-name>
| <multiplicity>Many</multiplicity>
| <relationship-role-source>
| <ejb-name>Experience</ejb-name>
| </relationship-role-source>
| </ejb-relationship-role>
| </ejb-relation>
jbosscmp-jdbc.xml
<ejb-relation>
| <ejb-relation-name>Person - experience</ejb-relation-name>
| <foreign-key-mapping/>
| <ejb-relationship-role>
| <ejb-relationship-role-name>PersonToExp</ejb-relationship-role-name>
| </ejb-relationship-role>
| <ejb-relationship-role>
| <ejb-relationship-role-name>ExpToPerson</ejb-relationship-role-name>
| <key-fields>
| <key-field>
| <field-name>id</field-name> <!-- primary key in person -->
| <column-name>Person_experience</column-name> <!-- foreign key
column in experience -->
| </key-field>
| </key-fields>
| </ejb-relationship-role>
| </ejb-relation>
I am in great need of help, and have not been able to find any solution that seems
applicable. Would be thankful for any ideas of what to do.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989757#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...