9 Replies Latest reply: Nov 28, 2012 5:59 AM by shiko RSS

    problem with master-detail

    shiko
      Hi everybody
      i have a problem with master detail ,i made page that contains 2 BC first is master and second is detail but when i press button create insert at master i got the following error
      Detail entity Projects with row key oracle.jbo.Key[7 ] cannot find or invalidate its owning entity.
      can anybody help me to solve this problem.
      thanx in advance

      Edited by: shiko on Nov 13, 2012 12:07 PM
        • 1. Re: problem with master-detail
          user404
          For a master do Create, for detail CreateInsert
          • 2. Re: problem with master-detail
            shiko
            thank you for your help
            i tried to use create but still got the same error
            • 3. Re: problem with master-detail
              codigoadf
              Hi,

              this thread myabe will help you {thread:id=2155272}
              • 4. Re: problem with master-detail
                shiko
                thank you for your help
                i saw this before sending my question because i didn't know where can i put this code
                @Override
                public void setNewRowState(byte b) {
                if (b != Row.STATUS_INITIALIZED || getNewRowState() != Row.STATUS_NEW) {
                super.setNewRowState(b);
                }
                }
                so if know where should be write this code i can try it
                • 5. Re: problem with master-detail
                  codigoadf
                  in your EntityImpl java class
                  • 6. Re: problem with master-detail
                    shiko
                    i try to write ut but i got compile error Error(430,40): cannot find method getNewRowState()

                    please see my entity imp code
                    package model;
                    ---------------------------------------------------------------------
                    import java.math.BigDecimal;

                    import oracle.jbo.AttributeList;
                    import oracle.jbo.Key;
                    import oracle.jbo.Row;
                    import oracle.jbo.RowIterator;
                    import oracle.jbo.domain.Number;
                    import oracle.jbo.server.AttributeDefImpl;
                    import oracle.jbo.server.EntityDefImpl;
                    import oracle.jbo.server.EntityImpl;
                    import oracle.jbo.server.SequenceImpl;
                    import oracle.jbo.server.TransactionEvent;
                    // ---------------------------------------------------------------------
                    // --- File generated by Oracle ADF Business Components Design Time.
                    // --- Tue Nov 13 18:56:18 AST 2012
                    // --- Custom code may be added to this class.
                    // --- Warning: Do not modify method signatures of generated methods.
                    // ---------------------------------------------------------------------
                    public class ProjectsImpl extends EntityImpl {
                    /**
                    * AttributesEnum: generated enum for identifying attributes and accessors. Do not modify.
                    */
                    public enum AttributesEnum {
                    ProjectId {
                    public Object get(ProjectsImpl obj) {
                    return obj.getProjectId();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setProjectId((Number)value);
                    }
                    }
                    ,
                    SubsidiaryId {
                    public Object get(ProjectsImpl obj) {
                    return obj.getSubsidiaryId();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setSubsidiaryId((BigDecimal)value);
                    }
                    }
                    ,
                    UserCode {
                    public Object get(ProjectsImpl obj) {
                    return obj.getUserCode();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setUserCode((String)value);
                    }
                    }
                    ,
                    PrimaryName {
                    public Object get(ProjectsImpl obj) {
                    return obj.getPrimaryName();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setPrimaryName((String)value);
                    }
                    }
                    ,
                    SecondaryName {
                    public Object get(ProjectsImpl obj) {
                    return obj.getSecondaryName();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setSecondaryName((String)value);
                    }
                    }
                    ,
                    Address {
                    public Object get(ProjectsImpl obj) {
                    return obj.getAddress();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setAddress((String)value);
                    }
                    }
                    ,
                    ProfitePercentage {
                    public Object get(ProjectsImpl obj) {
                    return obj.getProfitePercentage();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setProfitePercentage((BigDecimal)value);
                    }
                    }
                    ,
                    DepreciationPercentage {
                    public Object get(ProjectsImpl obj) {
                    return obj.getDepreciationPercentage();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setDepreciationPercentage((BigDecimal)value);
                    }
                    }
                    ,
                    BillOfQuantity {
                    public Object get(ProjectsImpl obj) {
                    return obj.getBillOfQuantity();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setAttributeInternal(index(), value);
                    }
                    }
                    ,
                    ProjectGroups {
                    public Object get(ProjectsImpl obj) {
                    return obj.getProjectGroups();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setAttributeInternal(index(), value);
                    }
                    }
                    ,
                    Subsidaries {
                    public Object get(ProjectsImpl obj) {
                    return obj.getSubsidaries();
                    }

                    public void put(ProjectsImpl obj, Object value) {
                    obj.setSubsidaries((SubsidariesImpl)value);
                    }
                    }
                    ;
                    private static AttributesEnum[] vals = null;
                    private static int firstIndex = 0;

                    public abstract Object get(ProjectsImpl object);

                    public abstract void put(ProjectsImpl object, Object value);

                    public int index() {
                    return AttributesEnum.firstIndex() + ordinal();
                    }

                    public static int firstIndex() {
                    return firstIndex;
                    }

                    public static int count() {
                    return AttributesEnum.firstIndex() + AttributesEnum.staticValues().length;
                    }

                    public static AttributesEnum[] staticValues() {
                    if (vals == null) {
                    vals = AttributesEnum.values();
                    }
                    return vals;
                    }
                    }


                    public static final int PROJECTID = AttributesEnum.ProjectId.index();
                    public static final int SUBSIDIARYID = AttributesEnum.SubsidiaryId.index();
                    public static final int USERCODE = AttributesEnum.UserCode.index();
                    public static final int PRIMARYNAME = AttributesEnum.PrimaryName.index();
                    public static final int SECONDARYNAME = AttributesEnum.SecondaryName.index();
                    public static final int ADDRESS = AttributesEnum.Address.index();
                    public static final int PROFITEPERCENTAGE = AttributesEnum.ProfitePercentage.index();
                    public static final int DEPRECIATIONPERCENTAGE = AttributesEnum.DepreciationPercentage.index();
                    public static final int BILLOFQUANTITY = AttributesEnum.BillOfQuantity.index();
                    public static final int PROJECTGROUPS = AttributesEnum.ProjectGroups.index();
                    public static final int SUBSIDARIES = AttributesEnum.Subsidaries.index();

                    /**
                    * This is the default constructor (do not remove).
                    */
                    public ProjectsImpl() {
                    }


                    /**
                    * @return the definition object for this instance class.
                    */
                    public static synchronized EntityDefImpl getDefinitionObject() {
                    return EntityDefImpl.findDefObject("model.Projects");
                    }

                    /**
                    * Gets the attribute value for ProjectId, using the alias name ProjectId.
                    * @return the value of ProjectId
                    */
                    public Number getProjectId() {
                    return (Number)getAttributeInternal(PROJECTID);
                    }

                    /**
                    * Sets <code>value</code> as the attribute value for ProjectId.
                    * @param value value to set the ProjectId
                    */
                    public void setProjectId(Number value) {
                    setAttributeInternal(PROJECTID, value);
                    }

                    /**
                    * Gets the attribute value for SubsidiaryId, using the alias name SubsidiaryId.
                    * @return the value of SubsidiaryId
                    */
                    public BigDecimal getSubsidiaryId() {
                    return (BigDecimal)getAttributeInternal(SUBSIDIARYID);
                    }

                    /**
                    * Sets <code>value</code> as the attribute value for SubsidiaryId.
                    * @param value value to set the SubsidiaryId
                    */
                    public void setSubsidiaryId(BigDecimal value) {
                    setAttributeInternal(SUBSIDIARYID, value);
                    }

                    /**
                    * Gets the attribute value for UserCode, using the alias name UserCode.
                    * @return the value of UserCode
                    */
                    public String getUserCode() {
                    return (String)getAttributeInternal(USERCODE);
                    }

                    /**
                    * Sets <code>value</code> as the attribute value for UserCode.
                    * @param value value to set the UserCode
                    */
                    public void setUserCode(String value) {
                    setAttributeInternal(USERCODE, value);
                    }

                    /**
                    * Gets the attribute value for PrimaryName, using the alias name PrimaryName.
                    * @return the value of PrimaryName
                    */
                    public String getPrimaryName() {
                    return (String)getAttributeInternal(PRIMARYNAME);
                    }

                    /**
                    * Sets <code>value</code> as the attribute value for PrimaryName.
                    * @param value value to set the PrimaryName
                    */
                    public void setPrimaryName(String value) {
                    setAttributeInternal(PRIMARYNAME, value);
                    }

                    /**
                    * Gets the attribute value for SecondaryName, using the alias name SecondaryName.
                    * @return the value of SecondaryName
                    */
                    public String getSecondaryName() {
                    return (String)getAttributeInternal(SECONDARYNAME);
                    }

                    /**
                    * Sets <code>value</code> as the attribute value for SecondaryName.
                    * @param value value to set the SecondaryName
                    */
                    public void setSecondaryName(String value) {
                    setAttributeInternal(SECONDARYNAME, value);
                    }

                    /**
                    * Gets the attribute value for Address, using the alias name Address.
                    * @return the value of Address
                    */
                    public String getAddress() {
                    return (String)getAttributeInternal(ADDRESS);
                    }

                    /**
                    * Sets <code>value</code> as the attribute value for Address.
                    * @param value value to set the Address
                    */
                    public void setAddress(String value) {
                    setAttributeInternal(ADDRESS, value);
                    }

                    /**
                    * Gets the attribute value for ProfitePercentage, using the alias name ProfitePercentage.
                    * @return the value of ProfitePercentage
                    */
                    public BigDecimal getProfitePercentage() {
                    return (BigDecimal)getAttributeInternal(PROFITEPERCENTAGE);
                    }

                    /**
                    * Sets <code>value</code> as the attribute value for ProfitePercentage.
                    * @param value value to set the ProfitePercentage
                    */
                    public void setProfitePercentage(BigDecimal value) {
                    setAttributeInternal(PROFITEPERCENTAGE, value);
                    }

                    /**
                    * Gets the attribute value for DepreciationPercentage, using the alias name DepreciationPercentage.
                    * @return the value of DepreciationPercentage
                    */
                    public BigDecimal getDepreciationPercentage() {
                    return (BigDecimal)getAttributeInternal(DEPRECIATIONPERCENTAGE);
                    }

                    /**
                    * Sets <code>value</code> as the attribute value for DepreciationPercentage.
                    * @param value value to set the DepreciationPercentage
                    */
                    public void setDepreciationPercentage(BigDecimal value) {
                    setAttributeInternal(DEPRECIATIONPERCENTAGE, value);
                    }

                    /**
                    * getAttrInvokeAccessor: generated method. Do not modify.
                    * @param index the index identifying the attribute
                    * @param attrDef the attribute

                    * @return the attribute value
                    * @throws Exception
                    */
                    protected Object getAttrInvokeAccessor(int index, AttributeDefImpl attrDef) throws Exception {
                    if ((index >= AttributesEnum.firstIndex()) && (index < AttributesEnum.count())) {
                    return AttributesEnum.staticValues()[index - AttributesEnum.firstIndex()].get(this);
                    }
                    return super.getAttrInvokeAccessor(index, attrDef);
                    }

                    /**
                    * setAttrInvokeAccessor: generated method. Do not modify.
                    * @param index the index identifying the attribute
                    * @param value the value to assign to the attribute
                    * @param attrDef the attribute

                    * @throws Exception
                    */
                    protected void setAttrInvokeAccessor(int index, Object value, AttributeDefImpl attrDef) throws Exception {
                    if ((index >= AttributesEnum.firstIndex()) && (index < AttributesEnum.count())) {
                    AttributesEnum.staticValues()[index - AttributesEnum.firstIndex()].put(this, value);
                    return;
                    }
                    super.setAttrInvokeAccessor(index, value, attrDef);
                    }

                    /**
                    * @return the associated entity oracle.jbo.RowIterator.
                    */
                    public RowIterator getBillOfQuantity() {
                    return (RowIterator)getAttributeInternal(BILLOFQUANTITY);
                    }

                    /**
                    * @return the associated entity oracle.jbo.RowIterator.
                    */
                    public RowIterator getProjectGroups() {
                    return (RowIterator)getAttributeInternal(PROJECTGROUPS);
                    }

                    /**
                    * @return the associated entity SubsidariesImpl.
                    */
                    public SubsidariesImpl getSubsidaries() {
                    return (SubsidariesImpl)getAttributeInternal(SUBSIDARIES);
                    }

                    /**
                    * Sets <code>value</code> as the associated entity SubsidariesImpl.
                    */
                    public void setSubsidaries(SubsidariesImpl value) {
                    setAttributeInternal(SUBSIDARIES, value);
                    }


                    /**
                    * @param projectId key constituent

                    * @return a Key object based on given key constituents.
                    */
                    public static Key createPrimaryKey(Number projectId) {
                    return new Key(new Object[]{projectId});
                    }

                    /**
                    * Add attribute defaulting logic in this method.
                    * @param attributeList list of attribute names/values to initialize the row
                    */
                    protected void create(AttributeList attributeList) {
                    SequenceImpl seq = new SequenceImpl("Projects_SEQ", getDBTransaction());
                    Number seqNextval;
                    seqNextval = seq.getSequenceNumber();
                    setProjectId(seqNextval);
                    super.create(attributeList);
                    }

                    /**
                    * Add entity remove logic in this method.
                    */
                    public void remove() {
                    super.remove();
                    }

                    /**
                    * Add locking logic here.
                    */
                    public void lock() {
                    super.lock();
                    }

                    /**
                    * Custom DML update/insert/delete logic here.
                    * @param operation the operation type
                    * @param e the transaction event
                    */
                    protected void doDML(int operation, TransactionEvent e) {
                    /* if (operation==DML_INSERT)
                    {

                    SequenceImpl seq = new SequenceImpl("Projects_SEQ", getDBTransaction());
                    Number seqNextval;
                    seqNextval = seq.getSequenceNumber();
                    setProjectId(seqNextval);
                    }*/
                    super.doDML(operation, e);
                    }
                    public void setNewRowState(byte b) {
                    if (b != Row.STATUS_INITIALIZED || getNewRowState() != Row.STATUS_NEW) {
                    super.setNewRowState(b);
                    }
                    }

                    }
                    • 7. Re: problem with master-detail
                      kdario
                      You can use getNewRowState() in ViewObjectImpl class
                      EntityImpl has getEntityState() method: http://docs.oracle.com/cd/E15051_01/apirefs.1111/e10653/oracle/jbo/server/EntityImpl.html

                      Dario
                      • 8. Re: problem with master-detail
                        shiko
                        hi all
                        i'm really tired from this error i have been tried all possible solutions but i still get the error,i want to ask question is there any problem if my master table have ,more than one detail table at ADF .
                        please if any body have any solution or idea let me know
                        thank you in advance

                        Edited by: shiko on Nov 27, 2012 8:53 AM
                        • 9. Re: problem with master-detail
                          shiko
                          please I need help