Mapping CMP EJBs to existing tables

Did I miss something or is there really no way to map container managed EJBs to existing tables?
As you seemingly only can map fields of an entity bean to tables done in a dictionary project I can't think of a way to do it unless there is a way to trick dictionary projects to resemble existing tables instead of tables managed by the dictionary.
This really prevents porting many existing apps to NW04 the 'easy way'.

Hi,
it is possible to create the persistent.xml without existing dictionary project, i.e. to specify OR Mapping to existing DB schema without having dictionary project defined for it. The SAP Netweaver IDE will report a warning as its validations will fail, but this will not break the build.
Of course it is possible to create a fake dictionary project and omit its deployment as you think this will save time.
Detailed information about the perisstent.xml structure can be found in the IDE help (or at help.sap.com)
Developing Enterprise Beans  -> Enterprise Bean Structure -> persistent.dtd
Regards,
Svetoslav
Message was edited by: Svetoslav Manolov

Similar Messages

  • Map CMP bean to two tables

    Hi,
    I have two tables.
    Customer table (CustId, Name, Address, StatusId)
    CustomerStatusCodes table (StatusID, StatusDesc)
    and I have a CMP for Customer.
    It has these attributes.
    custId,name,address, statusId,statusDesc
    How can I map customer CMP to both these tables.
    Thanking You,
    Chamal.

    In EJB 3.0 (within your Customer CMP):
        @ManyToOne
        @JoinColumn(name = "status_id",
                    referencedColumnName = "CUSTOMER_STATUS_CODES.status_id")
        public StatusId getStatusId() {
            return statusId;
        }Lookup ManyToOne if you want to see more specific examples.

  • Migrating CMP EJB mapped to SQL Server table with identity column from WL

    Hi,
        I want to migrate an application from Weblogic to SAP Netweaver 2004s (7.0). We had successfully migrated this application to an earlier version of Netweaver. I have a number of CMP EJBs which are mapped to SQL Server tables with the PK as identity columns(autogenerated by SQL Server). I am having difficulty mapping the same in persistant.xml. This scenario works perfectly well in Weblogic and worked by using ejb-pk in an earlier version of Netweaver.
       Please let me know how to proceed.
    -Sekhar

    I suspect it is the security as specified in the message. E.g .your DBA set the ID columns so no user can override values in it.
    And I suggest you 1st put the data into a staging table, then push it to the destination, this does not resolve the issue, but ensures better processing.
    Arthur
    MyBlog
    Twitter

  • How to mapping Entity beans to existing database tables.

    dear all
    how can i mapping Entity beans to existing database tables and not to create new table in Orion.
    thanks for any input.
    seabin

    * You define the name of the table that an Entity EJB maps to in orion-ejb-jar.xml. For eg:<entity-deployment name="MyEntityEJB" data-source="MyDS" table="MY_DB_TABLE" ...>* If you don't want to let Orion create the tables for your EJBs, have the following entry in either of the files given below:<orion-application autocreate-tables="false" ...>1) <orion-home>/j2ee/home/config/application.xml (global effect)
    2) orion-application.xml file of that particular application (application specific)
    HTH.

  • Mapping Entity beans to existing database tables.

    Hi All,
    I am using the RI of the J2EE (1.3.1) server provided by SUN. While deploying an entity bean I don't want to create a table by default, I want it to map to an existing table in the database. I find no DB column/EJB field mapping facility in the deploytool.
    Is it not possible or am I missing something....
    Thx n Rgds
    Lorenzo

    Hi!
    I'm using a different J2EE server (OC4J). But got this from the J2EE RI guide.
    If you do not want the container to create the table during deployment, follow these steps:
    1. In the Application Deployment Tool, select the Entity tab of the entity bean.
    2. In the Entity tabbed pane, click Deployment Settings.
    3. In the Deployment Settings dialog box, de-select the checkbox for "Create Table on Deploy."
    HTH.

  • Additional field in join table for CMP EJB

    Hello,
    I'm trying to perform this task using CMP entity beans:
    The entity A has a CMR relation of cardinality m-n with entity B (bidirectional) (This is working fine).
    I want to add a parameter to the relation.
    Ex : When I find that A1 is linked to B1, I need to perform "x" times an action. x would be my parameter, and I would have kept this parameter as an additional column in the join table A_TO_B.
    Could anyone provide an example of how to perform this with CMP EJB?
    NOTE: I'm using OC4J 10g 9.0.4 standalone (and cannot change my version).
    Thanks
    Tanguy

    Manohar,
    You need to create an append structure for table VBAP (for example ZAVBAP) using SE11. In this structure you create your ZZ fields. If you need a non-SAP domain/data element for your field then you need to create it first using the same transaction and activate it. Attach ZAVBAP to VBAP so the SE11 shows:
    .APPEND in the Fields column and
    ZAVBAP in the Field type column.
    Your ZZ fields will be shown automatically.
    When you have finished then activate your ZAVBAP structure. You will notice when you go VA01 (for example) that a lot of programs are being recompiled. Don't worry. It will be ok.
    The user-exit screen number for items is 8459 (in program SAPMV45A).
    Thanks,
    Wojtek

  • CMP EJB in 1.1/1.2..., mapping problems

    Hello,
    I'm a little bit confused by all these different EJB specifications and products...
    I want to use CMP EJB, because as far as I understand this topic, the container should do a lot of work for me (transaction management, connection pooling) and all tutorials tell me to prefer CMP ;-)
    Now I've got a Java class (to became my CMP EJB) like this:
    class doc {
    Descriptor descr;
    String body;
    and another class:
    class descriptor {
    int id;
    String title;
    My database contains two tables for both classes:
    table descr:
    id int (primary key);
    title varchar;
    table doc:
    fk_descr int; // foreign key to descr
    body varchar;
    Is it possible to make a CMP EJB using these two tables and using a Descriptor object? Which versions of EJB can handle this? Do you have any expirience with that?
    All examples I've read are always using only one table and classes containing only basic types like int, String.
    Thank you,
    Jens

    What you've described is a 1-1 relationship between two classes, which is not supported by CMP until EJB 2.0.
    -Peris

  • One class map to two existing tables

    I have two existing tables, inventoryTbl and supplierTbl
    inventoryTbl has following columns:
    inventoryIdCol ( Primary Key )
    inventoryTypeCol
    inventoryAmountCol
    supplierIdCol ( Foreign key to supplierTbl )
    supplierTbl has following columns:
    supplierIdCol ( Primary Key )
    supplierNameCol
    supplierAddressCol
    I have on JDO Class called inventory which want to map to the above
    two tables.
    it has all these fields:
    inventoryId;
    inventoryType
    inventoryAmount
    supplierIdCol
    supplierName
    supplierAddress
    How do I implement it?
    Question 1:
    Notice Kodo DTD has fk and join extension. Can I use them to implement?
    If so, could you give us an example? there is no example in the Kodo
    package.
    Question 2:
    Notice Kodo Developer guide mention the key-column and ref-column.
    But by definition, they are only used for Collection/Map field type.
    My case is neither of them. they can not be used in my case?
    Question 3:
    Any other way? Kodo developer guide mention the 'custom-mapping'
    extension. How do I use it?
    thanks,
    John

    Answer 1: There are no fk and join extensions. They are used in our
    reversemapping process. Kodo 3.0 has more verbose extensions (if
    you want to look at that (beta) version's documentation).
    Answer 2: You won't need them to map your situation (see later)
    Answer 3: I would suggest against this... it is not a trivial task nor
    well documented and WILL change with our upcoming 3.0 release (which is
    far easier to customize and documentation-wise).
    All those things being said, short of trying out Kodo 3.0 which is in
    (early) beta form, the easiest way is to map the supplierTbl to its own
    class. Note that this class does not have to be exposed at the
    application level. For example:
    public class Inventory {
    private Supplier supplier;
    public String getSupplierName () {
    return supplier.getSupplierName ();
    public void setSupplierName (String name) {
    supplier.setSupplierName (name);
    One can do more funky stuff using javax.jdo.InstanceCallbacks (jdoPostLoad
    () and jdoPreStore ()), however, I find the above strategy to be the
    easiest as it doesn't require any JDO dependencies in your application
    classes as well as requiring a lower level of undestanding of the
    PersistenceCapable lifecycle.
    On Thu, 14 Aug 2003 20:19:54 +0000, w wrote:
    >
    I have two existing tables, inventoryTbl and supplierTbl
    inventoryTbl has following columns:
    inventoryIdCol ( Primary Key )
    inventoryTypeCol
    inventoryAmountCol
    supplierIdCol ( Foreign key to supplierTbl )
    supplierTbl has following columns:
    supplierIdCol ( Primary Key )
    supplierNameCol
    supplierAddressCol
    I have on JDO Class called inventory which want to map to the above
    two tables.
    it has all these fields:
    inventoryId;
    inventoryType
    inventoryAmount
    supplierIdCol
    supplierName
    supplierAddress
    How do I implement it?
    Question 1:
    Notice Kodo DTD has fk and join extension. Can I use them to implement?
    If so, could you give us an example? there is no example in the Kodo
    package.
    Question 2:
    Notice Kodo Developer guide mention the key-column and ref-column.
    But by definition, they are only used for Collection/Map field type.
    My case is neither of them. they can not be used in my case?
    Question 3:
    Any other way? Kodo developer guide mention the 'custom-mapping'
    extension. How do I use it?
    thanks,
    John--
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • Deployment error: The Entity EJB requires the table:  to be accessible

    Hello
    When I deploy my EJBs, WEBLogic throws an exception:
    Unable to deploy EJB: OrderBean from ejb-jar-ic.jar:
    The Entity EJB requires the table: Order to be accessible. Please ensure that th
    is table exists and is accessible.
    I use built in Cloudscape database.
    And I have those lines in descriptor:
    <weblogic-rdbms-bean>
    <ejb-name>OrderBean</ejb-name>
    <data-source-name>ejbDS</data-source-name>
    <table-name>Order</table-name>
    <field-map>
    <cmp-field>totalAmount</cmp-field>
    <dbms-column>totalAmount</dbms-column>
    </field-map>
    <field-map>
    <cmp-field>time</cmp-field>
    <dbms-column>ordertime</dbms-column>
    </field-map>
    <field-map>
    <cmp-field>orderID</cmp-field>
    <dbms-column>orderID</dbms-column>
    </field-map>
    </weblogic-rdbms-bean>
    <create-default-dbms-tables>True</create-default-dbms-tables>
    thanx in advance
    Maris

    Hi Maris,
    I see that you have create-default-dbms-tables set to true so WLS should be creating
    the database table for your EJB. If you can give me some more information, I'll be
    able to help you further. What version of WLS + service pack are you using? Also,
    is this a 1.1 bean or 2.0? Lastly, what are the types of the CMP fields in your
    bean?
    As a work-around, you can try creating the database table yourself before deploying
    the bean. This should resolve the deployment problem.
    - Matt
    Maris wrote:
    Hello
    When I deploy my EJBs, WEBLogic throws an exception:
    Unable to deploy EJB: OrderBean from ejb-jar-ic.jar:
    The Entity EJB requires the table: Order to be accessible. Please ensure that th
    is table exists and is accessible.
    I use built in Cloudscape database.
    And I have those lines in descriptor:
    <weblogic-rdbms-bean>
    <ejb-name>OrderBean</ejb-name>
    <data-source-name>ejbDS</data-source-name>
    <table-name>Order</table-name>
    <field-map>
    <cmp-field>totalAmount</cmp-field>
    <dbms-column>totalAmount</dbms-column>
    </field-map>
    <field-map>
    <cmp-field>time</cmp-field>
    <dbms-column>ordertime</dbms-column>
    </field-map>
    <field-map>
    <cmp-field>orderID</cmp-field>
    <dbms-column>orderID</dbms-column>
    </field-map>
    </weblogic-rdbms-bean>
    <create-default-dbms-tables>True</create-default-dbms-tables>
    thanx in advance
    Maris

  • Challenge of the day - CMR existing tables

    Hey all!
    I have an existing application that contains 1:N table relationships that are already populated with data. How can I convert the EJB's (EJB2.0/CMP2.0) to use CMR?
    As a reference, I have tried this with Jboss 3.2.2 and XDoclet and have only had success with @jboss:auto-key-fields which will make a third table that is blank and only populated when data is added through the EJB relationship, not the existing populated data (that, and why use a third table?).
    Maybe this is the only way, not sure as new to CMR, can anyone be my hero and enlighten me please?

    I guess I'm still a little confused about some parts
    of this. I do already have existing tables (with
    indicies). I do have one big question:
    With CMR, will I be required to create a third table
    for the relationship?
    If not, then it seems that as long as the correct
    mappings (within CMP) have taken place, I should be
    immediately up and running without changes. This is
    the route I initially took with:
    * @jboss.relation
    * related-pk-field="mypk"
    * fk-column="mypk_fk"
    But unfortunately I must have missed something as can
    not get it to work correctly. If someone can help
    point me to one way (a third table) or the other
    (pk/fk mapping within CMP) that will help me on my
    way!Well, here it follows what I'm doing for my People-Address (1:1) relationships and which is working:
         //persistent-relationships
         * @ejb.interface-method
         * view-type="local"
         * @ejb.relation
         * name="People-Address"
         * role-name="1-People-1-Address"
         * multiple="no"
         * target-role-name="1-Address-1-People"
         * target-multiple="no"
         * target-ejb="Address"
         * @jboss.relation
         * fk-constraint="true"
         * related-pk-field="addressId"
         * fk-column="addressId"
         public abstract AddressLocal getHomeAddress();
    AddressLocal is obviously the LocalInterface of the Address entity bean and here we are within the People bean (which is supposed to be the main table). In a relationship, it's important to understand that both the source (People entity in this case) and the target (Address entity in this case) must be set. If there could be more than one Address for one People, than you would have set:
    ...snip
         * @ejb.relation
         * name="People-Address"
         * role-name="1-People-N-Address"
         * multiple="yes"
         * target-role-name="1-Address-1-People"
         * target-multiple="no"
         * target-ejb="Address"
    Hope it will help,
    Marco

  • Trouble saving date in CMP EJB on OC4J

    I have a CMP EJB that I'm trying to update and there is a field that maps to date type in the table.
    I get the following error when I try to assign a string literal of the type YYYY-MM-DD:
    javax.ejb.EJBException: Error saving state: ORA-01861: literal does not match format string
    How do you know what format string the container is using/expecting to pass to the database???
    How can you specify that? The EJB itself has the field as a String, not a Date. Should it be a Date?
    The OC4J container created it that way to begin with.
    I'm using JDeveloper with embedded OC4J and the database is 8i.

    Yes, the CMP-field's Java type should be Date. On the database side, the column-type is DATE.

  • Weblogic Deployment Descriptor for CMP EJB

    Hi all,
    Am new to EJB, CMP. Pls help me how to write deployment descriptors for the CMP EJB for Weblogic.
    Give me the list of the Deployment descriptors needed and also pls give me some samples
    thanks in advance
    rgds
    Ravi Bharathi

    The easiest way is to go through some tutorial or refer the code samples. If you have installed weblogic, there are examples provided in the weblogic installation folder itself for each type of bean. Basically for cmp you have to provide the table names and mapping between the class variables to db fields in weblogic_cmp_rdbms.xml deployment descriptor.

  • Compilation errors with CMP EJBs in OC4J

    I have created several new EJB's in JDeveloper using the
    EJB creation wizard. For most of them I chose the CMP Entity Beans from Tables wizard. Now I have already created some EJB's this way and have used them successfully. But for some reason when I try to start my OC4J, I get the following error messages for all my new EJB's:
    Error creating table: java.sql.SQLException: ORA-00955: name is already used by an existing object
    Why is this?

    The out-of-the-box behaviour of OC4J is to try to create tables for CMP beans when they are deployed. It sounds like a redeployment may be occuring bwhen you restart OC4J which is causing it to try and create the tables.
    I think that even though you see these error messages, the container will start and your beans will function.
    You can do one of two things to alter this situation if you want
    a) manually drop the tables from the db before you do the next deployment
    b) set the default behaviour of OC4J to drop tables when an application is undeployed (which happens before a redeployment is done) -- this can be done by setting an additional attribute on the j2ee/home/config/application.xml file -- "autodelete-tables=true"
    -steve-

  • Question abou CMP EJB

    those days i read the book 'enterprise java bean'
    i got some question while reading.
    1. in CMP EJB the container will take care the connect to the database and while deployment the ejb it will create the finder methods ( and other SQL statements ) right ?
    2. in CMP EJB, where is the database? i look some deployment file, can not find any thing about database.so where is it? and how container connect the database, it use jdbc as well ?
    3. When using EJB, the client part will run ejb sever as well? i think the ejb sever part will run the sever, the client will not, right?
    thanks for answer those questions. your help will be very appreciated.
    thanks

    those days i read the book 'enterprise java bean'
    i got some question while reading.
    1. in CMP EJB the container will take care the connect
    to the database and while deployment the ejb it will
    create the finder methods ( and other SQL statements )
    right ?
    If is is BMP (Bean Managed Persistence) then you have to do it, if it has CMP (Container Managed Persistence) then the container will do it for you.
    2. in CMP EJB, where is the database? i look some
    deployment file, can not find any thing about
    database.so where is it? and how container connect the
    database, it use jdbc as well ?
    The mapping between the EJB and the database is done in a vendor specific xml file, where you map the columns of the table(s) in the database to the fields in your EJB. In that XML file you will reference the database that you will use by referencing a connection pool or datasource.
    3. When using EJB, the client part will run ejb sever
    as well? i think the ejb sever part will run the
    sever, the client will not, right?The Client part doesn't run any container. You have to create a context to the Container running the EJB and then find it and use it.
    MSB

  • Running CMP EJB in remote OC4J fails, works in embedded. Oracle 9i

    I more or less followed the EJB Tutorial (in the help) for creating a session-entity bean facade from Oracle 9i tables. Everything executes correctly in the embedded oc4j but it fails on the remote oc4j with
    java.sql.SQLException: Invalid column name
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:292)
         at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:5632)
         at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:716)
         at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1506)
         at com.evermind.sql.FilterResultSet.getString(FilterResultSet.java:585)
         at EmployeeLocalHome_EntityHomeWrapper13.findAll(EmployeeLocalHome_EntityHomeWrapper13.java:1260)
    Then I also created another simpler CMP EJB that just has 3 fields from Oracle table. This one doesn't even work in embedded oc4j :
    com.evermind.server.rmi.OrionRemoteException: Database error: ORA-01747: invalid user.table.column, table.column, or column specification
         java.util.Collection TimesheetHoursHome_EntityHomeWrapper11.findAll()
    Are there any known problems I should look out for with generating CMP EJBS with wizards?
    I think the IDE is more intuitive than WSAD. It would be great it things worked though.
    Another question is regarding relationships. Do the wizards always use ejb-refs to implement relationships? It should be easy enough to add them with EJB Editor if they do not.
    Thanks for any help.

    Known issues are documented in the release notes
    http://otn.oracle.com/products/jdev/htdocs/readme_903Preview.html#ejb
    <<<Another question is regarding relationships. Do the wizards always use ejb-refs to implement relationships? >>>>
    Not sure what you meant here. If you reverse engineer let us say DEPT and EMP tables, foreign key relationships between the tables are reverse engineered as CMR but there aren't any ejb-ref/ejb-local-ref tags which get generated in the deployment descriptor.
    <<It should be easy enough to add them with EJB Editor if they do not. >>
    You can double-click on the EJB to bring the EJB Module Editor and select "Relationships" node to add/edit/delete relationships visually.
    raghu
    JDev Team

Maybe you are looking for