• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 493
  • Last Modified:

Auto Create table in JDeveloper


 I am writing EJB application and used CMR. To develop this application I am using JDeveloper (Oracle 9i-OC4J).  When I run this application, it autometically creates CMR tables. But I don't want to that  JDeveloper should create auto table, for that I have configured in application.xml
 <orion-application autocreate-tables="false" ...>. still now it creates auto table and generates  identifire is  to long error.
                 
 I don't want to auto create table, I want to cofigure that it uses our databse tables. so
 give any solution what will be configuration, as soon as possible.
0
vilabs
Asked:
vilabs
  • 6
  • 5
  • 2
1 Solution
 
vzilkaCommented:
Are your database tables really created?
Can you post ejb-jar.xml and orion-ejb-jar.xml in here?
0
 
vilabsAuthor Commented:
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
  <enterprise-beans>
    <entity>
      <description>Entity Bean ( CMP )</description>
      <display-name>Patient</display-name>
      <ejb-name>Patient</ejb-name>
      <home>com.vilabs.ipd.ejb.entity.PatientHome</home>
      <remote>com.vilabs.ipd.ejb.entity.Patient</remote>
      <local-home>com.vilabs.ipd.ejb.entity.PatientLocalHome</local-home>
      <local>com.vilabs.ipd.ejb.entity.PatientLocal</local>
      <ejb-class>com.vilabs.ipd.ejb.entity.PatientBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Long</prim-key-class>
      <reentrant>False</reentrant>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Patient</abstract-schema-name>
      <cmp-field>
        <field-name>patient_id</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>mrd_no</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>casualty_no</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>opd_no</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>first_name</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>last_name</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>sex</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>marital_status</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>religion</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>guardian_relation</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>guardian_first_name</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>guardian_last_name</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>phone_number</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>occupation</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>income</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>inactive</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>address_detail_id</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>last_updated</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>updated_by</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>active_flag</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>age_year</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>age_months</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>age_days</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>emailid</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>patient_category</field-name>
      </cmp-field>
      <primkey-field>patient_id</primkey-field>
    </entity>

    <entity>
      <description>Entity Bean ( CMP )</description>
      <display-name>Patient_address</display-name>
      <ejb-name>Patient_address</ejb-name>
      <home>com.vilabs.ipd.ejb.entity.Patient_addressHome</home>
      <remote>com.vilabs.ipd.ejb.entity.Patient_address</remote>
      <local-home>com.vilabs.ipd.ejb.entity.Patient_addressLocalHome</local-home>
      <local>com.vilabs.ipd.ejb.entity.Patient_addressLocal</local>
      <ejb-class>com.vilabs.ipd.ejb.entity.Patient_addressBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Long</prim-key-class>
      <reentrant>False</reentrant>
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Patient_address</abstract-schema-name>
      <cmp-field>
        <field-name>address_id</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>address</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>address2</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>city</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>state</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>country</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>pin</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>last_updated</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>updated_by</field-name>
      </cmp-field>
      <cmp-field>
        <field-name>active_flag</field-name>
      </cmp-field>
      <primkey-field>address_id</primkey-field>
      <ejb-local-ref>
        <ejb-ref-name>PatientLocal</ejb-ref-name>
        <ejb-ref-type>Entity</ejb-ref-type>
        <local-home>com.vilabs.ipd.ejb.entity.PatientLocalHome</local-home>
        <local>com.vilabs.ipd.ejb.entity.PatientLocal</local>
        <ejb-link>Patient</ejb-link>
      </ejb-local-ref>
    </entity>
</enterprise-beans>
 <relationships>
    <ejb-relation>
      <ejb-relation-name>Patient_Address</ejb-relation-name>
      <ejb-relationship-role>
        <multiplicity>One</multiplicity>
        <relationship-role-source>
          <ejb-name>Patient</ejb-name>
        </relationship-role-source>
        <cmr-field>
          <cmr-field-name>pt_Address</cmr-field-name>
          <cmr-field-type>java.util.Collection</cmr-field-type>
        </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
        <multiplicity>Many</multiplicity>
        <relationship-role-source>
          <ejb-name>Patient_address</ejb-name>
        </relationship-role-source>
        <cmr-field>
          <cmr-field-name>patient</cmr-field-name>
        </cmr-field>
      </ejb-relationship-role>
    </ejb-relation>
</ejb-jar>

orion.xml

    <entity-deployment name="Patient" data-source="jdbc/oracleDS" table="PATIENT">
      <primkey-mapping>
        <cmp-field-mapping name="patient_id" persistence-name="PATIENT_ID" persistence-type="NUMBER(20)"/>
      </primkey-mapping>
      <cmp-field-mapping name="patient_id" persistence-name="PATIENT_ID" persistence-type="NUMBER(20)"/>
      <cmp-field-mapping name="mrd_no" persistence-name="MRD_NO" persistence-type="VARCHAR2(10)"/>
      <cmp-field-mapping name="casualty_no" persistence-name="CASUALTY_NO" persistence-type="VARCHAR2(10)"/>
      <cmp-field-mapping name="opd_no" persistence-name="OPD_NO" persistence-type="VARCHAR2(10)"/>
      <cmp-field-mapping name="first_name" persistence-name="FIRST_NAME" persistence-type="VARCHAR2(30)"/>
      <cmp-field-mapping name="last_name" persistence-name="LAST_NAME" persistence-type="VARCHAR2(30)"/>
      <cmp-field-mapping name="sex" persistence-name="SEX" persistence-type="VARCHAR2(15)"/>
      <cmp-field-mapping name="marital_status" persistence-name="MARITAL_STATUS" persistence-type="VARCHAR2(20)"/>
      <cmp-field-mapping name="religion" persistence-name="RELIGION" persistence-type="VARCHAR2(30)"/>
      <cmp-field-mapping name="guardian_relation" persistence-name="GUARDIAN_RELATION" persistence-type="VARCHAR2(5)"/>
      <cmp-field-mapping name="guardian_first_name" persistence-name="GUARDIAN_FIRST_NAME" persistence-type="VARCHAR2(50)"/>
      <cmp-field-mapping name="guardian_last_name" persistence-name="GUARDIAN_LAST_NAME" persistence-type="VARCHAR2(50)"/>
      <cmp-field-mapping name="phone_number" persistence-name="PHONE_NUMBER" persistence-type="VARCHAR2(14)"/>
      <cmp-field-mapping name="occupation" persistence-name="OCCUPATION" persistence-type="VARCHAR2(30)"/>
      <cmp-field-mapping name="income" persistence-name="INCOME" persistence-type="VARCHAR2(15)"/>
      <cmp-field-mapping name="inactive" persistence-name="INACTIVE" persistence-type="VARCHAR2(6)"/>
      <cmp-field-mapping name="address_detail_id" persistence-name="ADDRESS_DETAIL_ID" persistence-type="NUMBER(20)"/>
      <cmp-field-mapping name="last_updated" persistence-name="LAST_UPDATED" persistence-type="DATE"/>
      <cmp-field-mapping name="updated_by" persistence-name="UPDATED_BY" persistence-type="NUMBER(20)"/>
      <cmp-field-mapping name="active_flag" persistence-name="ACTIVE_FLAG" persistence-type="CHAR(1)"/>
      <cmp-field-mapping name="age_year" persistence-name="AGE_YEAR" persistence-type="NUMBER(4)"/>
      <cmp-field-mapping name="age_months" persistence-name="AGE_MONTHS" persistence-type="NUMBER(4)"/>
      <cmp-field-mapping name="age_days" persistence-name="AGE_DAYS" persistence-type="NUMBER(4)"/>
      <cmp-field-mapping name="emailid" persistence-name="EMAILID" persistence-type="VARCHAR2(30)"/>
      <cmp-field-mapping name="patient_category" persistence-name="PATIENT_CATEGORY" persistence-type="VARCHAR2(30)"/>
      <cmp-field-mapping name="pt_Address">
        <collection-mapping table="PATIENT_ADDRESS">
          <primkey-mapping>
            <cmp-field-mapping>
              <entity-ref home="Patient">
                <cmp-field-mapping persistence-name="PATIENT_ID" persistence-type="NUMBER(20)"/>
              </entity-ref>
            </cmp-field-mapping>
          </primkey-mapping>
          <value-mapping type="com.vilabs.ipd.ejb.entity.Patient_addressLocal">
            <cmp-field-mapping>
              <entity-ref home="Patient_address">
                <cmp-field-mapping persistence-name="ADDRESS_ID" persistence-type="NUMBER(20)"/>
              </entity-ref>
            </cmp-field-mapping>
          </value-mapping>
        </collection-mapping>
      </cmp-field-mapping>
    </entity-deployment>


<entity-deployment name="Patient_address" data-source="jdbc/oracleDS" table="PATIENT_ADDRESS">
      <primkey-mapping>
        <cmp-field-mapping name="address_id" persistence-name="ADDRESS_ID" persistence-type="NUMBER(20)"/>
      </primkey-mapping>
      <cmp-field-mapping name="address_id" persistence-name="ADDRESS_ID" persistence-type="NUMBER(20)"/>
      <cmp-field-mapping name="address" persistence-name="ADDRESS" persistence-type="VARCHAR2(60)"/>
      <cmp-field-mapping name="address2" persistence-name="ADDRESS2" persistence-type="VARCHAR2(60)"/>
      <cmp-field-mapping name="city" persistence-name="CITY" persistence-type="VARCHAR2(15)"/>
      <cmp-field-mapping name="state" persistence-name="STATE" persistence-type="VARCHAR2(15)"/>
      <cmp-field-mapping name="country" persistence-name="COUNTRY" persistence-type="VARCHAR2(15)"/>
      <cmp-field-mapping name="pin" persistence-name="PIN" persistence-type="VARCHAR2(8)"/>
      <cmp-field-mapping name="last_updated" persistence-name="LAST_UPDATED" persistence-type="DATE"/>
      <cmp-field-mapping name="updated_by" persistence-name="UPDATED_BY" persistence-type="NUMBER(20)"/>
      <cmp-field-mapping name="active_flag" persistence-name="ACTIVE_FLAG" persistence-type="CHAR(1)"/>
      <cmp-field-mapping name="patient_id" persistence-name="PATIENT_ID" persistence-type="NUMBER(20)"/>
      <cmp-field-mapping name="patient">
        <entity-ref home="Patient">
          <cmp-field-mapping persistence-name="PATIENT_ID" persistence-type="NUMBER(20)"/>
        </entity-ref>
      </cmp-field-mapping>
    </entity-deployment>



   This code is similar for another entity bean Emeregency_contect_address and primary key for this bean  is address_id when I make one to many relatioship between patient and    Emeregency_contect_address entity bean then JDdeveloper creates one more table, which contain two fields both field are primary key of each bean and name of field is combination of table name + primary key field name . so its field lenght become greater than 30 character. and gives identifier is to long error.

           But I don't want that  JDeveloper should create auto  table, for that I have configure that in application.xml autocreatetable attribute false.  but its not working.




 
0
 
vilabsAuthor Commented:

   Please give if any solution as soon as possible. For this problem I have made shot length name of table and primary key but I don't think this is right solution.
 
                                           
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
vzilkaCommented:
Does the table already exist in the database?
0
 
vilabsAuthor Commented:
Ya table is already exist .  Rrelationship table is created by JDeveloper at the deployment time of deployment descriptor file.
0
 
vzilkaCommented:
But if the table exists, and JDev tries to create it, it will just print a not-too-important error on the screen.
Is this the behavior you recieve?
0
 
vilabsAuthor Commented:
This behavior didn't receive . When it create table , it  gives identifire is too long. That why  bean not successfully deployed.
                        One more question can u give orion-ejb-jar.xml mapping code for one to one and many to many  ralationship between two entities.
0
 
vilabsAuthor Commented:
Hi,
I am tring to implement 1:1 relationship between two entities Patient and Patient_Address, for that I have written mapping code inside orion-ejb-jar.xml file such that
in patient side

<cmp-field-mapping name="pt_Emer_Address">
<entity-ref home="Pt_emer_addr">
<cmp-field-mapping persistence-name="PATIENT_ID" persistence-type="NUMBER(20)"/>
</entity-ref>
</cmp-field-mapping>

whare pt_Emer_Address is cmr field
and in Patient_Address side

<cmp-field-mapping name="patient">
<entity-ref home="Patient">
<cmp-field-mapping persistence-name="PATIENT_ID" persistence-type="NUMBER(20)"/>
</entity-ref>
</cmp-field-mapping>

where patient is cmr field.

I call create method of Patient_AddressLocalHome. And inside ejbPostCreate method, first find out patient, then I call setPt_Emer_Address(ptLocal). But it gives NoSuchObjectException.
The post create code is

 public void ejbPostCreate(Long address_id, Date last_updated, Long updated_by, String active_flag, Long patient_id)
    {
        System.out.println(" ejbPostCreate ");
        postCreate(patient_id);
    }


public void postCreate(Long patient_id)
{
try{
PatientLocalHome ptLocalHome= getPatientLocalHome();
PatientLocal ptLocal = ptLocalHome.findByPrimaryKey(patient_id);
System.out.println(" pt local "+ptLocal);
System.out.println(" Name "+ptLocal.getFirst_name());
System.out.println("Context Object " + context.getEJBLocalObject());
ptLocal.setPt_Emer_Address((Pt_emer_addrLocal)context.getEJBLocalObject());

} catch (Exception ex) {
context.setRollbackOnly();
ex.printStackTrace();
}
}

so please tell me this is orion-ejb-jar.xml mapping code problem or other problem.If orion-ejb-jar.xml problem than tell me exact mapping coding.

                       I am confused that it is necessary to  write explicit mapping code for 1:1 ,1:M, M:M relationship in orion-ejb-jar.xml file,  I am using JDev.
0
 
vzilkaCommented:
Regarding the first question (let's solve this one first), which identifier is too long? Can you give an exception stack trace?

Regarding the orion-ejb-jar.xml question, which JDev version are you using?
0
 
vilabsAuthor Commented:
Regarding first question
      When  I run MyEjbSessionBean.java then it gives given below such error.

Auto-deploying file:/D:/Workspace4/Project1/classes/ (No previous deployment found)...
Auto-creating table: create table Mrd_emergency_contact_a_aqv61w (Mrd_emergency_contact_address_ADDRESS_ID NUMBER not null)

done.

Oracle9iAS (9.0.3.0.0) Containers for J2EE initialized

Error creating table: ORA-00972: identifier is too long

         I am using Jdev903 version.

0
 
vzilkaCommented:
It seems your table name is too long. Can you change it? (I think it is done through the orion-ejb-jar.xml file).
Also, try to move to JDev 9.0.5 - it offers more control on the orion-ejb-jar.xml management.
0
 
kimbad01Commented:
The maximum length of a table name in oracle is 30 characters. The table name is 30 characters however the column name exceeds this so I suspect this is the problem.

An example of the orion-ejb.jar follows:

<orion-ejb-jar>
  <enterprise-beans>
    <entity-deployment name="Test" data-source="jdbc/MyDS" table="TEST">
      <primkey-mapping>
        <cmp-field-mapping name="id" persistence-name="ID" persistence-type="NUMBER(10)"/>
      </primkey-mapping>
      <cmp-field-mapping name="id" persistence-name="ID" persistence-type="NUMBER(10)"/>
      <cmp-field-mapping name="data" persistence-name="DATA" persistence-type="VARCHAR2(80)"/>
    </entity-deployment>
  </enterprise-beans>
  <assembly-descriptor>
    <default-method-access>
      <security-role-mapping impliesAll="true" name="&lt;default-ejb-caller-role>"/>
    </default-method-access>
  </assembly-descriptor>
</orion-ejb-jar>
0
 
kimbad01Commented:
I still think the problem was that the column name was too long not the table name. The table name is 30 characters which is allowable. The column name exceeds this same max value.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 6
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now