Avatar billede dn666 Nybegynder
15. juli 2003 - 13:56 Der er 2 kommentarer og
1 løsning

Manglende key ?

Jeg bruger xdoclet til at generere mine cmp'ere med men jeg er rendt ind i et problem med relationships.

jboss brokker sig over at der ikke er et key field
den siger:

org.jboss.deployment.DeploymentException: Atleast one role of a foreign-key mapped relationship must have key fields (or <primkey-field> is missing from ejb-jar.xml): ejb-relation-name=Subtitle_master - Status_ids

Jeg kan ikke hitte ud af hvad det er der mangler.

jeg prøver at lave en one-to-one relation.


her er Status_idsBean klassen, med xdoclet taggene:

package dk.stream.ejb;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.CreateException;
import java.util.Collection;

/**
* @ejb.bean
*      name="Status_ids"
*      type="CMP"
*      view-type="local"
*      local-jndi-name="local/Status_ids"
*      primkey-field="status_id"
*      schema="Status_ids"
*      cmp-version="2.x"
*      view-type="local"
* @ejb.value-object
*      name="Status_ids"
*      match="*"
* @ejb.transaction
*      type="Required"
* @ejb.util
*      generate="physical"
* @ejb:pk class="java.lang.String"
*
* @ejb:home generate="local"
* @ejb:finder
*      signature= "java.util.Collection findAll()"
*      query ="SELECT OBJECT(o) FROM Status_ids AS o"
*
*  @jboss:create-table false
*  @jboss:remove-table false
*/

public abstract class Status_idsBean implements EntityBean  {
    private EntityContext context;
    /**
    *  @ejb.create-method
    */
    public String ejbCreate(String status_id, String descrip) throws CreateException {
        setStatus_id(status_id);
        setDescrip(descrip);
        return status_id;
    }

    public void ejbPostCreate(String status_id, String descrip) {
    }

    public void ejbActivate() {
    }

    public void ejbLoad() {
    }

    public void ejbPassivate() {
    }

    public void ejbRemove() {
    }

    public void ejbStore() {
    }

    public void setEntityContext(EntityContext ctx) {
        this.context = ctx;
    }

    public void unsetEntityContext() {
        this.context = null;
    }

  /** @ejb:pk-field
    *  @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract String getStatus_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setStatus_id(String newStatus_id);


    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract String getDescrip();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setDescrip(String newDescrip);

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="File_repository - Status_ids"
    *  role-name="File_repository has a Status_ids"
    *  multible="no"
    */
    public abstract Status_idsLocal getFile_repository_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setFile_repository_status_id(Status_idsLocal newFile_repository_status_id);

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="Filetypes - Status_ids"
    *  role-name="Filetypes has a Status_ids"
    *  multible="no"
    */
    public abstract Status_idsLocal getFiletypes_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setFiletypes_status_id(Status_idsLocal newFiletypes_status_id);

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="Codec_master - Status_ids"
    *  role-name="Codec_master has a Status_ids"
    *  multible="no"
    */
    public abstract Status_idsLocal getCodec_master_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setCodec_master_status_id(Status_idsLocal newCodec_master_status_id);

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="Clip_parts - Status_ids"
    *  role-name="Clip_parts has a Status_ids"
    *  multible="no"
    */
    public abstract Status_idsLocal getClip_parts_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setClip_parts_status_id(Status_idsLocal newClip_parts_status_id);

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="Clip_master - Status_ids"
    *  role-name="Clip_master has a Status_ids"
    *  multible="no"
    */
    public abstract Status_idsLocal getClip_master_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setClip_master_status_id(Status_idsLocal newClip_master_status_id);

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="Users - Status_ids"
    *  role-name="Users has a Status_ids"
    *  multible="no"
    */
    public abstract Status_idsLocal getUsers_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setUsers_status_id(Status_idsLocal newUsers_status_id);

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="Subtitle_master - Status_ids"
    *  role-name="Subtitle_master has a Status_ids"
    *  multible="no"
    */
    public abstract Status_idsLocal getSubtitle_master_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setSubtitle_master_status_id(Status_idsLocal newSubtitle_master_status_id);

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="Groups - Status_ids"
    *  role-name="Groups has a Status_ids"
    *  multible="no"
    */
    public abstract Status_idsLocal getGroups_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setGroups_status_id(Status_idsLocal newGroups_status_id);
}

og her er metoderne i Subtitle_masterBean:

    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    * @ejb:relation
    *  name="Subtitle_master - Status_ids"
    *  role-name="Status_ids belongs to Subtitle_master"
    *  cascade-delete="no"
    *  multible="no"
    * @jboss.target-relation
    *  fk-column="status_id"
    *  fk-constraint = "false"
    *  related-pk-field="status_id"
    */
    public abstract Status_idsLocal getStatus_ids_status_id();
    /** @ejb:interface-method view-type="local"
    *  @ejb:persistent-field
    */
    public abstract void setStatus_ids_status_id(Status_idsLocal newStatus_ids_status_id);





når jeg så kører xdoclet bliver min ejb-jar.xml genereret, her er en snip til Status_ids.

      <entity >
        <description><![CDATA[No Description.]]></description>

        <ejb-name>Status_ids</ejb-name>

        <local-home>dk.stream.ejb.Status_idsLocalHome</local-home>
        <local>dk.stream.ejb.Status_idsLocal</local>

        <ejb-class>dk.stream.ejb.Status_idsBean</ejb-class>
        <persistence-type>Container</persistence-type>
        <prim-key-class>java.lang.String</prim-key-class>
        <reentrant>False</reentrant>
        <cmp-version>2.x</cmp-version>
        <abstract-schema-name>Status_ids</abstract-schema-name>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>status_id</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>descrip</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>file_repository_status_id</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>filetypes_status_id</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>codec_master_status_id</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>clip_parts_status_id</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>clip_master_status_id</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>users_status_id</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>subtitle_master_status_id</field-name>
        </cmp-field>
        <cmp-field >
            <description><![CDATA[]]></description>
            <field-name>groups_status_id</field-name>
        </cmp-field>
        <primkey-field>status_id</primkey-field>

        <query>
            <query-method>
              <method-name>findAll</method-name>
              <method-params>
              </method-params>
            </query-method>
            <ejb-ql><![CDATA[SELECT OBJECT(o) FROM Status_ids AS o]]></ejb-ql>
        </query>

      </entity>



og relationship stykket:

      <ejb-relation >
        <ejb-relation-name>Subtitle_master - Status_ids</ejb-relation-name>
        <!-- bidirectional -->
        <ejb-relationship-role >
            <ejb-relationship-role-name>Subtitle_master has a Status_ids</ejb-relationship-role-name>
            <multiplicity>One</multiplicity>
            <relationship-role-source >
              <ejb-name>Status_ids</ejb-name>
            </relationship-role-source>
            <cmr-field >
              <cmr-field-name>subtitle_master_status_id</cmr-field-name>
            </cmr-field>
        </ejb-relationship-role>
        <ejb-relationship-role >
            <ejb-relationship-role-name>Status_ids belongs to Subtitle_master</ejb-relationship-role-name>
            <multiplicity>One</multiplicity>
            <relationship-role-source >
              <ejb-name>Subtitle_master</ejb-name>
            </relationship-role-source>
            <cmr-field >
              <cmr-field-name>status_ids_status_id</cmr-field-name>
            </cmr-field>
        </ejb-relationship-role>
      </ejb-relation>
      <ejb-relation >
Avatar billede dn666 Nybegynder
15. juli 2003 - 14:00 #1
noget andet.
jeg har prøvet at bruge @ejb.persistence i stedet for @ejb.persistent-field, da @ejb.persistent-field er depricated, men så bliver cmp-field ikke genereret ???
Avatar billede dn666 Nybegynder
15. juli 2003 - 14:28 #2
Har hittet ud af noget der virker...
jeg skiftede:

    * @jboss.target-relation
    *  fk-column="status_id"
    *  fk-constraint = "false"
    *  related-pk-field="status_id"

ud med:

    * @jboss.relation
    *  fk-column="status_id"
    *  fk-constraint = "false"
    *  related-pk-field="status_id"


men nu brokker den sig:

        [-4005] (at 27): Unknown column name:FILE_REPOSITORY_STATUS_ID

hvor faen får den det fra???
Avatar billede dn666 Nybegynder
20. januar 2005 - 14:29 #3
Luk
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester