Hello,

I have this relation wich I want to put in my ejb:

Person -------0..*--[personmaterial]--*..0------Material

So, the personmaterial ejb is a link table wich has a foreignkey of person and of material. Person and material only have a entity bean wich is used by personmaterial. Personmaterial has also a session bean. The problem is , when I want to add a new personmaterial I get an error that my Material_id and person_id field can not be null. I just don't kno what I need to do to fill them in, I think I did everything that has to be done.

Since I can nowhere find descent information about the tags and the inner working of these tags, I assume that when I add the 'personVO' and the 'materialVO' to the 'personmaterialVO' the id's of person and material are automatically extracted and used in the query to store . Apparently this is not true or I am doing something wrong.

Test case:
_________

        MaterialVO book = new MaterialVO();
        book.setBook_isbn("5446845646");
        book.setShortdescription("boekse");
        book.setDiscriminator("2");
        book.setMaterialId(new Integer(10));

        PersonVO koen = new PersonVO();
        koen.setName("dsdsd");
        koen.setFirst_name("koen");
        koen.setMobile_phone("04143");
        koen.setPersonId(new Integer(10));

        MaterialPersonVO mpv = new MaterialPersonVO();
        mpv.setMaterialVO(book);
        mpv.setPersonVO(koen);

        materialpersonremote=getMaterialPersonRemote();                             materialpersonremote.createMaterialPerson(mpv);

My CMR defenition in personmaterial
_______________________________

 /**
 * @ejb.interface-method
 *
 * @ejb.value-object
 *      aggregate="be.dataflow.diana2.main.domain.ejb.data.PersonVO"
 *      aggregate-name="PersonVO"
 *      members="be.dataflow.diana2.main.domain.ejb.interfaces.PersonLocal"
 *      members-name="Person"
 *      relation="external"

 * @ejb.relation
 *      name="materialPerson-person"
 *      role-name="materialPerson-has-person"
 *      cascade-delete="no"
 *      target-ejb="Person"
 *      target-role-name="person-is_refered_by-materialPerson"
 *      target-multiple="yes"
 *
 * @jboss.relation
 *      fk-column="PERSON_ID"
 *      related-pk-field="personId"
 *      fk-constraint = "true"
 *
 */

    public abstract PersonLocal getPerson();
    public abstract void setPerson( PersonLocal person );


    /**
 * @ejb.interface-method
 *
 * @ejb.value-object
 *      aggregate="be.dataflow.diana2.main.domain.ejb.data.MaterialVO"
 *      aggregate-name="MaterialVO"
 *      members="be.dataflow.diana2.main.domain.ejb.interfaces.MaterialLocal"
 *      members-name="Material"
 *      relation="external"
 * @ejb.relation
 *      name="materialPerson-material"
 *      role-name="materialPerson-has-material"
 *      cascade-delete="no"
 *      target-ejb="Material"
 *      target-role-name="material-is_refered_by-materialPerson"
 *      target-multiple="yes"
 *
 * @jboss.relation
 *      fk-column="MATERIAL_ID"
 *      related-pk-field="materialId"
 *     fk-constraint = "true"
 */

  public abstract MaterialLocal getMaterial();
  public abstract void setMaterial( MaterialLocal material);

Can any one point me out what I'm doing wrong ?

(The error)

10:45:56,593 ERROR [MaterialPerson] Could not create entity
java.sql.SQLException: General error,  message from server: "Column 'PERSON_ID'
cannot be null"
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1628)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:886)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:945)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:1809)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.jav

 



Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, and more

Reply via email to