EJB 3.0: CMP Entity bean from view

Hi,
I have created an entity bean from a database view.
I don't have a good filed to use as id in my view. So I want to generate the id in my entity bean.
How can I do this ?
Thanks

Hi,
I didn't get your question.
CMP is something, which can be done by hand.
So maybe it is better, to do it manually.
Bea has some workaround, I am sure.
Maybe it is something with deployment descriptors, which
have to be configured to the underlying database.
Sorry for my stupid first answer.
Volker.

Similar Messages

  • CMP entity beans from tables in 9.0.3 jdev preview

    I am trying to generate CMP entity beans from oracle tables using 9.0.3 jdeveloper preview. My oracle db version is 9.2. I notice that if a table has a single column primary key, no xxxPK.java file is created. However, if the primary key is multi-column an xxxPK.java file is created. Is this correct behavior? I expected an xxxPK.java file to be created regardless of the number of columns in the primary key for the table. Has anyone else noticed this? I am new to EJB so forgive my ignorance.

    Comparing to JDev 902, I think this is a much better decision. Having to change beans with a single field PK to not using a custon PK class, to avoid using that class was a pain in JDev 902. There4s little benefit in using a custom class when there4s only a single field in it... some will say that it prevents having to do majot changes to your code if the PK changes in the future and add another field. But a careful database design will void this almost completely. So having JDev 903 use a java native class is a better option in this situation. At least from my personal point of view.

  • Create CMP Entity Beans from Tables Wizard - Can't see any tables with DB2

    Hi,
    I'm trying to use the "Create CMP Entity Beans from Tables Wizard" to create an entity from a table in a DB2 database. The problem is, on page 2, I can't see any available tables. I have verified that the connection works (I can open the connection in the Navigator frame and I can see that table).
    Note that if I try this wizard on an Oracle database, I can see tables.
    WTF? Can someone please help?

    I second the motion. I too work in an environment with centralized data management (DBA's) that create and maintain all tables under a generic schema. This has prevented me from using the Create Entity Beans from Table feature of Jdev r3 preview.
    At least I can see that I'm not alone.
    Thanks
    When I select the "Create CMP Entity Beans from Tables Wizard," no tables or views are available to select. The JDev database connection is using an ID assigned to me.
    The tables that I am looking for were created by the DBA under his ID and are therefore in that schema. He did create Public Synonyms for them, but the tables still do not show up in the wizard.
    Is there a configuration step that I need to do to have those tables show up?
    Tables created by a DBA and then accessed by developers using a public synonym is a very common scenario and should be supported by JDeveloper (IMO).
    Thanks.
    I'm using JDev 9.0.2.8.2.

  • Problems accessing fields in a CMP entity bean from a session bean

    Hello everybody,
    I'm getting the next problem: when I try to access a field in a CMP entity bean that I have instantiated from a session bean (trhoug entitybean.getNameOfField), I get the error "the entity bean does not exist in the database".
    This entity bean is accessing a table in an external database (not the DB of the WAS), but I know that it's getting the correct data from the table, since  I check the entitybean.size() and the entitybean.findByPrimaryKey(), and I get the right information. For some reason, the only thing that it doesn't work in the entity bean are the getter/setter methods (I created them automatically after having created the entity fields).
    I access the entity bean through its local interface...
    I know it's really difficult to give an answer with so few details, but... does anybody think I forgot something important to configure??
    Thank very much in advance!!
    Isidro

    getter and setter methods for cmp-fields are abstract.
    getter and setter methods for cmr-fields are abstract.
    "John Lee" <[email protected]> wrote:
    >
    Hi:
    Which method in a CMP Entity bean should be abstract? just only SetXXX
    and
    GetXXX?
    Thanks!
    John Lee

  • CMP Entity Bean from dataBase views

    Hi forum,
    I Have to migrate an existing application to JEE (with EJB3).
    In this application there are a lot of dataBase views.
    I'm new in EJB3 and I don't know how to structure cleanly entity beans (Specially when it are created from dataBase views).
    My problem is that for each query made from the same dataBase view I almost have to create a new entity bean with a different @Id.
    What can I do to to avoid it?
    I had thought to genrate a new @Id (attribute not persistent) but I think is not possible. It's right ?
    Someone can help me ?
    Thanks

    "CMP provides you with database independence and less coding efforts."
    BMP is not database dependent, unless you invoke database specific things in your SQL (something I do not do). CMP on the otherhand is inherently appserver specific (which was it's goal when BEA, IBM, et al. came up with it), and still limits your design possibilities. See this thread for an example:
    http://forum.java.sun.com/thread.jsp?forum=13&thread=318785
    As for less coding effort, that is a relative statment. Yes a simple CMP bean requires less coding to develop the first time. I personally view a few lines of SQL to load and store the data as being fairly trivial. But that needs to be offset with the problems inherent in using appserver specific CMP implementations.
    As an example, try mapping WebSphere CMP to a pre-existing database without using IBM's IDE. It's an incredible pain in the ass since WebSphere does not come with a "meet-in-the-middle" solution. Any J2EE developer that has had the experience of working with different appservers (especially if they have had to port an app, as I have) can attest to the complications that arise with each implementation.
    A BMP bean, written with non-DB-specific SQL, is the most portable, most flexible approach to EntityBeans. Yes, it requires the developer to be able to write some SQL, which should not take a significant amout of time. WRT queries, you have to write them, either SQL, EQL, or some appserver specific format.
    As an aside, the use of code generators to simplify the creation of EJBs lends itself well to BMP. By using a (or writing your own) code generator, you can mitigate the annoying SQL bugs that creep up early in development.

  • Help with exception calling cmp entity bean from session bean

    Hi,
    I know someone else posted a very similar problem recently but I think the root of my problem may be different.
    This is the exception that I receive:
    javax.transaction.TransactionRolledbackException: CORBA TRANSACTION_ROLLEDBACK 9998 Maybe; nested exception is:
    org.omg.CORBA.TRANSACTION_ROLLEDBACK: vmcid: 0x2000 minor code: 1806 completed: Maybe
    at com.sun.corba.ee.internal.iiop.ShutdownUtilDelegate.mapSystemException(ShutdownUtilDelegate.java:114)
    at javax.rmi.CORBA.Util.mapSystemException(Util.java:65)
    at itsthes.security._SecurityManager_Stub.findUserRoles(Unknown Source)
    at itsthes.security._SecurityManager_Stub.findUserRoles(Unknown Source)
    at itsthes.security.servlets.SecurityUserListView.processRequest(SecurityUserListView.java:80)
    at itsthes.security.servlets.SecurityUserListView.doGet(SecurityUserListView.java:94)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:720)
    at org.apache.catalina.core.StandardWrapperValve.access$000(StandardWrapperValve.java:118)
    at org.apache.catalina.core.StandardWrapperValve$1.run(StandardWrapperValve.java:278)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:203)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:505)
    at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:157)
    at com.iplanet.ias.web.WebContainer.service(WebContainer.java:598)
    Caused by: org.omg.CORBA.TRANSACTION_ROLLEDBACK: vmcid: 0x2000 minor code: 1806 completed: Maybe
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    at java.lang.Class.newInstance0(Class.java:306)
    at java.lang.Class.newInstance(Class.java:259)
    at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemException(ReplyMessage_1_2.java:94)
    at com.sun.corba.ee.internal.iiop.LocalClientResponseImpl.getSystemException(LocalClientResponseImpl.java:120)
    at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOAClientSC.java:133)
    at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
    at itsthes.security._SecurityManager_Stub.findUserRoles(Unknown Source)
    ... 17 more
    This is my primary key implementation:
    public final class SecurityUserKey implements java.io.Serializable {
    public java.lang.Integer userId;
    public java.lang.Integer roleId;
    public java.lang.String emailAddress;
         * Creates an empty key for Entity Bean: SecurityUser
         public SecurityUserKey() {
    * @see java.lang.Object#equals(java.lang.Object)
    public boolean equals(java.lang.Object otherOb) {
    if (this == otherOb) {
    return true;
    if (!(otherOb instanceof itsthes.security.entitybeans.SecurityUserKey)) {
    return false;
    itsthes.security.entitybeans.SecurityUserKey other = (itsthes.security.entitybeans.SecurityUserKey) otherOb;
    return (
    (userId==null?other.userId==null:userId.equals(other.userId))
    (roleId==null?other.roleId==null:roleId.equals(other.roleId))
    (emailAddress==null?other.emailAddress==null:emailAddress.equals(other.emailAddress))
    * @see java.lang.Object#hashCode()
    public int hashCode() {
    return (
    (userId==null?0:userId.hashCode())
    ^
    (roleId==null?0:roleId.hashCode())
    ^
    (emailAddress==null?0:emailAddress.hashCode())
    My entity method invocation is this:
    public Collection findUserRoles() {
    Vector userCollection=new Vector();
    try {
    Context jndiContext = new InitialContext();
    LocalSecurityUserHome home = (LocalSecurityUserHome) jndiContext.lookup(this.securityUserBean);
    Iterator i = home.findAll().iterator();
    while ( i.hasNext() ) {
    LocalSecurityUser securityUser = (LocalSecurityUser)i.next();
    SecurityUser sessionBean=mapLocalSecurityUser(securityUser);
    userCollection.add(sessionBean);
    } catch (javax.naming.NamingException e) {
    System.err.println(e);
    } catch (javax.ejb.FinderException e) {
    System.err.println(e);
    return userCollection;
    If anyone could point me in the right direction that would be great.
    thanks,
    William

    Hi,
    The Transaction Rollback exception may be due to the SystemException thrown in your findUserRoles() code which force the container to rollback the transaction. catch the generic exception in your findUserRoles() code and veriy what went wrong.
    i hope this helps.
    -ram

  • EJB 2.0 cmp entity beans problem with 8.17

    I have a little application as client JBuilder,Weblogic 7.0 on the middleware
    and 8.17 personnal at the backend,with Cloudscape java database,it worked fine.
    I have two tables in it,with a one-to-many relationship,the ClientID from the Clients Table is foreign key in the other.
    But now with 8.17 I have a RollbackException(cannot create Factures instance with the foreign key field null)so I cannot create any instance at the many side from the relation because the ClientID which is with EJB2.0 not a cmp field,is put automatically by the container in the table,
    but this process seems not to work with 8.17,
    what can I do?
    Have someone a solution?

    Hi,
    I didn't get your question.
    CMP is something, which can be done by hand.
    So maybe it is better, to do it manually.
    Bea has some workaround, I am sure.
    Maybe it is something with deployment descriptors, which
    have to be configured to the underlying database.
    Sorry for my stupid first answer.
    Volker.

  • Composite Primary Key in M:N CMP Entity Bean Relationship

    Dear Sir/Madam,
         We are creating an Enterprise Application for our institute using EJB 2.0 specifiactions. In the course of developement, we are facing a problem in writing the CMP Entity Beans with EJB Relationships.
         We are having many to many relationship between two beans such that the primary key of one Entity Bean (let's call it A), serves as the foreign key of another Entity Bean (let's call it B). Further, this primary key of A as foreign key in B, participates in the composite key of B.
         The EJB Specifications require that the primary key field(s) of any bean (B, in our case) declared in the Primary Key class should be the subset of the 'cmp-field' declared in the deployment descriptor for that bean. As I said earlier, we have many to many relationship at play. Hence, we require to keep the foerign key in the 'cmr-field' in lieu of 'cmp-field'. In short, the component of primary key is in 'cmr-field' while, it is needed in both 'cmp-field' and 'cmr-field'. That's perfect from Database point of view but illogical from CMP Entity Bean's view.
         How can we write the deployment descriptor for such a CMP (BMP is working fine for above scenario) Entity Bean? Also, how can we write the Primary Key class? The problem is not just to find the solution, but find under the hood of EJB 2.0 specifications.
         Please help.

    I think you should realise that it would not be convenient to use CMP for everything. It is difficult to define complex relations using CMP. Mostly BMP os preferd since it gives the flexibility for the bean developer.
    Regards
    xH4x0r

  • Removing a CMP Entity Bean

    I'm trying to remove a CMP Entity Bean from my project but after I do this the application becomes useless. When I start the application afterwards I get such a warning:
    "TopLink found problems in toplink-ejb-jar. Please ensure that there are corrected before deployment"
    After that, at runtime, there are lots of DescriptorExceptions, IntegrityExceptions and NullPointerExceptions. When I added the bean once more I get a bunch of compilation errors because of multiple declarations of the bean methods. I removed the bean once again, closed JDeveloper and removed all reference to that bean within the project (grep). Despite that I am unable to get rid of the aforementioned errors. What should I do?

    I'm trying to remove a CMP Entity Bean from my project but after I do this the application becomes useless. When I start the application afterwards I get such a warning:
    "TopLink found problems in toplink-ejb-jar. Please ensure that there are corrected before deployment"
    After that, at runtime, there are lots of DescriptorExceptions, IntegrityExceptions and NullPointerExceptions. When I added the bean once more I get a bunch of compilation errors because of multiple declarations of the bean methods. I removed the bean once again, closed JDeveloper and removed all reference to that bean within the project (grep). Despite that I am unable to get rid of the aforementioned errors. What should I do?

  • CMP Entity Bean with ejb-ql finder methods and INFORMIX database

    Hi,
    I have some CMP Entity Beans with finder methods defined in ejb-ql. In my ejb-jar, within <entity> definitions I have something like:
        <entity>
          <abstract-schema-name>BeanName</abstract-schema-name>
          <cmp-field><field-name>fieldOne</field-name></cmp-field>
          <cmp-field><field-name>fieldTwo</field-name></cmp-field>
          <query>
            <query-method>
              <method-name>findAll</method-name>
              <method-params></method-params>
            </query-method>
            <ejb-ql>SELECT OBJECT(o) FROM BeanName o</ejb-ql>
          </query>
        <entity>
    And in persistent.xml:
    <db-properties>
         <data-source-name>datasource_name</data-source-name>
    </db-properties>
    <entity-bean>
         <ejb-name>BeanName</ejb-name>
         <table-name>table_name</table-name>
         <field-map key-type="NoKey">
         <field-name>fieldOne</field-name>
         <column><column-name>column_one</column-name></column>
          </field-map>
         <field-map key-type="NoKey">
         <field-name>fieldTwo</field-name>
         <column><column-name>column_two</column-name></column>
          </field-map>
          <finder-descriptor>
              <method-name>findAll</method-name>
              <method-params/>
         </finder-descriptor>
    Once deployed, on server side, I can found a java source file (with corresponding compiled class file) in path:
    j2ee/cluster/server0/apps/companyName/MyEARApp/EJBContainer/temp/temp38837373733/route/to/package/
    with names:
    BeanName0_0pm.java
    BeanName0_0PM.class
    and the generated java file contains this code:
      public java.util.Enumeration ejbFindAll() throws javax.ejb.FinderException, javax.ejb.EJBException  {
        TransactionContext tc = pm.getTransactionContext();
        Connection conn = null;
        PreparedStatement pSt = null;
        ResultSet ejb_rs = null;
        int status = javax.transaction.xa.XAResource.TMSUCCESS;
        try {
          conn = pm.getConnectionForFindMethod();
          pSt = conn.prepareStatement("SELECT \"O\".\"COLUMN_ONE\",\"O\".\"COLUMN_TWO\", FROM \"TABLE_NAME\" \"O\"");
          ejb_rs = pSt.executeQuery();
    I'm trying to call this method but it throws a SQLException when preparing the statement.
    It seems that Informix does not like this SQL syntax because of upper case names, doble quotes on table alias, or something else.
    When editing persistent.xml in netweaver, I can define the element <datasource-vendor> as ORACLE, SAPDB, MS_SQL_SERVER, DB2_UDB_AS400 or DB2_UDB_OS390 but INFORMIX is not an accepted value.
    Is there any way to define how this SQL query is build?
    Thanks in advance.

    The return type of the finder method defined in the remote home interface is either the entity bean's remote interface or a collection of objects implementing the entity bean's remote interface. The return type of the finder method defined in the local home interface is either the entity bean's local interface or a collection of objects implementing the entity bean's local interface

  • Calling stored procedures from CMP entity beans

    Hello all,
    Is it possible to call a stored procedure from a CMP entity bean? if so, what is the purpose of defining the <cmp-fields> in the descriptor file if I can just pass the result set of my query as an arraylist (or something similar), completely bypassing the need for the cmp fields? Am I missing something here?
    Please let me know.
    -Dave

    You can't call a stored procedure to populate your container managed fields. You need to use an updatable view or a table. You can create some other method in a CMP bean that calls a stored procedure however.

  • How to load the existing data from the databse in the CMP entity bean?

    hello
    my problem is as follows--
    i am creating a CMP entity bean.in these beans client create the data instances using create() function.
    now a entity bean will be created for the newly created data and it's EJBObject will also be formed.
    now we will be able to perform finder methods over them.
    remember these data has been newly created in the database.
    but now if i want to perform the finder methods on the
    existing data in the database( i don't need to use create() fn as i am not "creating" the data.). how will i perform the query over the existing data.
    basically i have to make a CMP bean to extract the data corresponding to a particular condition , from the database table. i don't want to create the data in the database but just find out what data satisfies my condition.
    thanking you
    Prashant

    you have to use findByXXX methods. depending on your appserver you may have to declare them (and eventually the query you want to be used) in the vendor specific deploiement descriptor.
    (e.g. using jboss i don't remember having explicitly declare the findBySomeField method - where someField is a persistent field - in the dd, whereas with bas all finder methods have to be explicitly declared)
    [note that obviously these methods have to be present in your home interface]

  • Error while using sybase trigger with the CMP entity bean,ejb version 2.1

    Hi All,
    I am using ejb version 2.1 and using entity bean (Transaction required) ,i am trying to update data in sybase(ver 12.3) database table
    I am using session bean(Transaction required) to update the multiple entity beans in a while loop.It is working fine .But when i am trying to run it with the trigger which updates multiple tables in different sybase databases on update of each entity.Then it throws NoSuchEntityException and it rollback the whole transaction.
    My trigger has only few simple update statements and the trigger runs fine without my CMP entity bean.is the CMP does not support the update triggers in sybase or is it the problem with the transaction.
    Please help
    Thanks
    Anshu

    If you can have a look at a cmp example in the samples that ship with the server. My guess is that the weblogic-ejb-jar.xml file is missing the <persistence-use> element which for 810 would look like:
    <persistence>
    <persistence-use>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>7.0</type-version>
    <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
    </persistence-use>
    </persistence>
    I seem to recall that the elements might be slightly different in structure for the wls700 version of the DTD, so please check that (I cannot, I'm at home and don't have everything here).
    Give that a try and see if it doesn't solve your compilation failure.
    Also, the compilation should not be throwing a null pointer exception in a case like that, I consider that to be a bug.
    -thorick

  • What are the necessary elements in ejb-jar.xml with CMP entity bean

    What are the necessary elements in ejb-jar.xml with CMP entity bean
    Actually i am using webligic 8.1 and while deployment getting the error that
    some elements r missing
    Thanks
    Anand Pritam

    According to the ejb-jar.xml dtd ejb-name, ejb-class, persistence-type, prim-key-class, reentrant are the required elements for an entity bean.
    <!ELEMENT entity (description?, display-name?, small-icon?,
              large-icon?, ejb-name, home?, remote?, local-home?,
              local?, ejb-class, persistence-type, prim-key-class,
              reentrant, cmp-version?, abstract-schema-name?,
              cmp-field*, primkey-field?, env-entry*, ejb-ref*,
              ejb-local-ref*, security-role-ref*, security-identity?,
              resource-ref*, resource-env-ref*, query*)>

  • Do I must include orion-ejb-jar.xml in my CMP entity bean?

    Deal all:
    I've had a problem about deployment of my CMP entity bean.
    I don't know if I need to include orion-ejb-jar.xml in the jar
    file? Could anyone tell me what files I should include them in
    jar file and what config file(like data-sources.xml) I should
    modify them?
    Thanks!!

    The orion-ejb-jar.xml is not necessary...oc4j/orion auto-
    generates this configuration file when the application is
    deployed. You would only need this file if you are using o-r
    mapping, or changing some deployment time option with your ejb.
    The config/data-sources.xml file is used by the container. If
    you are using oracle, you will need to use the data-sources.xml
    for your database (the path needs the proper database name, and
    server host, and you will need to put in the password and
    username). Use the example with the oc4j docs to help you, or
    the one already in your config directory.
    regards,
    the elephantwalker
    www.elephantwalker.com

Maybe you are looking for

  • Distortion Correction with Lookup Table

    Hello, I am trying to run an image through lookup tables in order to correct some distortion. I have two 2D lookup tables "LUTsXnew.raw" and "LUTsYnew.raw" which locate the new (x,y) coordinates that i want to move the pixel intensities from original

  • Trouble sending mail to a group

    HI, I set up a new group in my mail program and when I try to send it an error comes up saying "This message could not be delivered and will remain in your Outbox until it can be delivered. Sending the message content to the server failed." I believe

  • RW-50004 Warning while installation using rapidwiz

    Hi all, I am installing the 11i 11.5.10.2 into a single box linux system I am getting the RW-50004 Warning and the following details: Error Code received while running the external process. Check log for details Running database driver for VIS databa

  • Plant to plant stock trasnfer with excise duty

    Hi,   We have one company code and two plant assign to it , now one plant is Ma=fg. plant  and other plant is depot plant  , now I have purchase  material with excise duty in mfg. plant and excise is capture with J1IEX aprt1 and part2 is done   now o

  • Finally, after 3 mb's, 2 psu's, 2 sets of ram and 2 cpu's - the system is up!

    Hi all, After almost two months of waiting for rma'd replacement parts, my new NLE is finally up and running! As it turned out, it was the new processor that went bad - all along. But i feel i need to correct some of my incorrect assumptions in my pr