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

Similar Messages

  • Bad Performance/OutOfMemory Error in CMP Entity Bean with Large DB

    Hello:
    I have an CMP Entity deployed on WLS 7.0
    The entity bean maps to a table that has 97,480 records.
    It has a finder: findAll() -- SELECT OBJECT(e) FROM Equipment e
    I have a JSP client that invokes the findALL()
    The performance is very poor ~ 150 seconds just to perform the findAll() - (Benchmark
    from within the JSP code)
    If more than one simultaneous call is made then I get outOfMemory Error.
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>
    (without max-beans-in-cache directive the performance is worse)
    Is there any documentation available to help us in deploying CMP Entity Beans
    with very large number of records (instances) ?
    Any help is greatly appreciated.
    Regards
    Rajan

    Hi
    You should use a Select Method, it does support cursors.
    Or a Home Select Method combination.
    Regards
    Thomas
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>>
    (without max-beans-in-cache directive the performance is worse)>
    Is there any documentation available to help us in deploying CMP
    Entity Beans with very large number of records (instances) ? Any help
    is greatly appreciated.>
    Regards>
    Rajan>
    >
    "Rajan Jena" <[email protected]> schrieb im Newsbeitrag
    news:3dadd7d1$[email protected]..
    >
    Hello:
    I have an CMP Entity deployed on WLS 7.0
    The entity bean maps to a table that has 97,480 records.
    It has a finder: findAll() -- SELECT OBJECT(e) FROM Equipment e
    I have a JSP client that invokes the findALL()
    The performance is very poor ~ 150 seconds just to perform the findAll() -(Benchmark
    from within the JSP code)
    If more than one simultaneous call is made then I get outOfMemory Error.
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>
    (without max-beans-in-cache directive the performance is worse)
    Is there any documentation available to help us in deploying CMP EntityBeans
    with very large number of records (instances) ?
    Any help is greatly appreciated.
    Regards
    Rajan

  • Error While Deploying A CMP Entity Bean With A Composite Primary Key

    Hello all,
    I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
    In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
    [05/Jan/2005:12:49:03] WARNING ( 1896):      Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
    test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
         Update the type of the key class field.
         Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
         Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
    Please let me know if you need more information to answer my question.
    Thanks.
    Nikola

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • Caching CMP Entity Beans with 9.0.2

    Hi,
    my CMP Entity Bean is accessed from a JSP-Page through a Stateless Session Bean. The Session-Bean executes findAll() on the Entity-Bean and the JSP-Page iterates over the Collection and displays the Fields through their getter-Methods. It turns out that every getXXX Methods results in a complete load of the Bean from the Database, so for 3 database-records with 4 attributes i get 12 SELECT - statements and 12 Activate/Load/Passivate cycles of the Entity Bean!!!!
    I tried to setup the attributes in orion-ejb-jar.xml correctly, but that didn't show a difference:
    -) exclusive-write-access="true" does only work in "read-only" mode (see oc4j_ejb_guide_r2.pdf)
    -) setting timeouts didnt work
    My Entity Bean settings are:
    exclusive-write-access="true"
    instance-cache-timeout="60"
    max-instances="100"
    max-tx-retries="0"
    pool-cache-timeout="100"
    The EJB-Callbacks are:
    first the Session-Bean is created, and findAll() is executed - then all Entity-Beans are passivated again:
    TestManBean Constructor called 1
    TestManBean.setSessionContext() 1
    TestManBean.ejbCreate() 1
    PersonBean Constructor called 1
    PersonBean.setEntityContext() 1
    PersonBean.ejbActivate() 1
    PersonBean.ejbLoad() 1
    PersonBean Constructor called 2
    PersonBean.setEntityContext() 2
    PersonBean.ejbActivate() 2
    PersonBean.ejbLoad() 2
    PersonBean Constructor called 3
    PersonBean.setEntityContext() 3
    PersonBean.ejbActivate() 3
    PersonBean.ejbLoad() 3
    PersonBean.ejbPassivate() 1
    PersonBean.ejbPassivate() 2
    PersonBean.ejbPassivate() 3
    now for every getXXX-Methods the following occurs:
    PersonBean.ejbActivate() 3
    PersonBean.ejbLoad() 3
    PersonBean.ejbPassivate() 3
    I user OC4J 9.0.2 Production with Oracle 8.1.6.
    How can I turn on Entity-Bean Caching?
    Thanks,
    Gilbert

    Hi Gilbert,
    Someone recently asked a similar question to yours. Perhaps that thread will
    be helpful to you?
    Author: Valeri Kireitchik
    Subject: how to set exclusive-write-access="true"
    Date: May 17, 2002 10:18 PT
    URL:
    Re: Get the Table name by providing the Sequence name
    The same person (Valeri) also asked his question on two other forums:
    http://www.elephantwalker.com/rfa?id=549
    http://www.mail-archive.com/orion-interest%40orionserver.com/msg19037.html
    Good Luck,
    Avi.

  • CMP entity bean with compound primary key

    I'm trying to use a compound primary key in a CMP entity bean. I've created the custom primary key class okay, and I have the prim-key-class set in ejb-jar.xml. My client app gets the home reference okay, but when it tries to find an entity, I get the exception "SQLException: Incorrect syntax near '/'."
    I think I'm having trouble deploying this in OC4J. Is there a sample orion-ejb-jar.xml deployment for a custom, compound primary key somewhere?
    Many thanks for any help.
    Ernie

    Never mind. I solved my problem. Thanks.

  • ORA-01407 when removing a CMP Entity Bean with WLS 9.1

    Hi all !
    I hope you can help me to solve this ?:|
    I'm migrating my application from WLS 8.1 SP3 to WLS 9.1.
    I'm getting now an SQLException when I try to remove a CMP Entity Bean.
    The stacktrace is as follows:
    java.sql.SQLException: ORA-01407: cannot update ("USER"."MY_TABLE"."THE_CMR_FIELD") to NULL
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1120)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1278)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3415)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3498)
         at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:128)
    Of course, I replaced the table and column names above to be more readable ;-)
    The table MY_TABLE has a CMR field called THE_CMR_FIELD. The column is not nullable in the database (by the way, it's an Oracle 9i).
    Everything is fine under WLS8.1
    I tried two different Oracle JDBC drivers (9.2.0.5 and 10.2.0.1.0), but the result is always the same within WLS9.1.
    Any ideas or suggestions (or even questions) are more than welcome!
    Thanks
    Eric

    What's even more weird is that I have what seams to be the same problem on Weblogic 6.1 (SP4).
    Here's the stacktrace:
    <pre>
    javax.ejb.EJBException:
    Start server side stack trace:
    java.sql.SQLException: ORA-01407: cannot update ("SCHEMA"."TIM_WP_DAY_CORE_PERIODS"."TWD_ID") to NULL
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at com.p6spy.engine.logging.P6LogPreparedStatement.executeUpdate(P6LogPreparedStatement.java:183)
         at weblogic.jdbc.jts.Statement.executeUpdate(Statement.java:503)
         at package.WorkPatternDayCorePeriods_vd9y46__WebLogic_CMP_RDBMS.__WL_store(WorkPatternDayCorePeriods_vd9y46__WebLogic_CMP_RDBMS.java:2317)
         at weblogic.ejb20.manager.DBManager.flushModified(DBManager.java:438)
         at weblogic.ejb20.internal.TxManager$TxListener.flushModifiedKeys(TxManager.java:552)
         at weblogic.ejb20.internal.TxManager.flushModifiedBeans(TxManager.java:298)
         at weblogic.ejb20.manager.BaseEntityManager.flushModifiedBeans(BaseEntityManager.java:1246)
         at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.flushModifiedBeans(RDBMSPersistenceManager.java:1106)
         at weblogic.ejb20.manager.BaseEntityManager.cascadeDeleteRemove(BaseEntityManager.java:840)
         at weblogic.ejb20.manager.DBManager.remove(DBManager.java:656)
         at weblogic.ejb20.internal.EntityEJBLocalObject.remove(EntityEJBLocalObject.java:97)
         at package.WorkPatternDayCorePeriodsEJB_vd9y46_ELOImpl.remove(WorkPatternDayCorePeriodsEJB_vd9y46_ELOImpl.java:722)
         at package.PersonWorkPatternBC.removeWorkPatternDay(PersonWorkPatternBC.java:571)
         at package.remove(PersonWorkPatternBC.java:708)
         at package.TimPersonCalendarServiceEJB.removeWorkPattern(TimPersonCalendarServiceEJB.java:140)
    </pre>
    In fact I have this setup:
    <pre>
    workpattern 1..n workpatternday -| 1..n dayperiod
    | 1..n daycoreperiod
    </pre>
    And before 'ejbRemove'ing the workpattern I first remove the days and before that the periods and core periods.
    I start with the periods and instead of removing them in the DB he tries to update the FK to the day with '' (p6spy result).
    When I remove the not null constraint on the foreign key everything passes to the day where the workpatternId cannot be set to null.
    He does not throw errors on the coreperiod (where the not null constraint to day is still present).
    When I invert the sequence of deleting
    (first the core periods then the 'regular' periods) he complains about the dayId on the core periods table.
    So it's completely absurd :S
    I hope weblogic 8.1 might solve this problem as this development code is still to be migrated to 8.1 before going in production...
    I would just like to know what's wrong. There are other places with just about the same relationships (CMR and DB) where he does not complain...

  • CMP Entity Bean With Primary Key of int

    Is it valid to have a CMP Entity Bean (v1.1) where the primary key is defined as the primitive 'int' instead of a true Java class?
    Thanks in advance,
    Marc

    Hi,
    Ur primary key in the EJB cant be a primitive data type. If the primary key in the table is a int,
    then u will hv [bold] java.lang.Integer [bold] as the datatype in Entity Bean. If u hv further queries write me at [email protected]
    Kesavan.

  • BMP-/CMP-Entity Beans with JBoss 3.0 & MySQL 3.23

    Hi @all!
    Sorry, I`m a beginner in development of EJBs, but I`ve got already two of them (a session bean, a cmp-bean with Hypersonic DB) running.
    Now my question:
    Is it possible to develop bmp- or cmp-beans with JBuilder 6.0 and AppServer JBoss 3.0 and MySQL as relational database.
    If anybody here, has ever done this.
    Please contact for one or two short questions like:
    What will I have to do to get MySQL as persistence medium in JBoss?
    What will I have to do to get MySQL by a bmp-entity-bean over JNDI?
    What will I have to do to run my program? ;-)
    I�m always getting error messages like:
    ...no such entity...
    Or:
    ...MyDB not bound...
    Thanks
    Michael

    Now, I`ve done a little step in the right direction:
    It is possible to create CMP-Beans with JBoss 3.0 and MySQL database.
    You just have to put both on the same machine ;-) (Incredible...)
    But now I`ve got problems to implement a bean-managed-persistence Bean with JBoss 3.0 and mySQL.
    If I start my client application, I get the following error messages, although my EJB is correctly deployed:
    -- I`m calling: create(17, max, [email protected])
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
         java.rmi.ServerException: null
    Embedded Exception
    null; nested exception is:
         javax.ejb.EJBException: null
    Embedded Exception
    null
         at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:292)
         at sun.rmi.transport.Transport$1.run(Transport.java:148)
         at java.security.AccessController.doPrivileged(Native Method)-- Erfolglos: create(17, max, [email protected])
         at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
         at java.lang.Thread.run(Thread.java:536)
         at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:250)
         at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:226)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:136)
         at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
         at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:128)
         at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:108)
         at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:73)
         at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:76)
         at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:185)
         at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:76)
         at $Proxy0.create(Unknown Source)
         at gaestebuch.BMPTestClient.create(BMPTestClient.java:71)
         at gaestebuch.BMPTestClient.main(BMPTestClient.java:309)
    Caused by: java.rmi.ServerException: null
    Embedded Exception
    null; nested exception is:
         javax.ejb.EJBException: null
    Embedded Exception
    null
         at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:119)
         at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:167)
         at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
         at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:104)
         at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
         at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
         at org.jboss.ejb.Container.invoke(Container.java:726)
         at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
         at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:362)
         at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
         at sun.rmi.transport.Transport$1.run(Transport.java:148)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
         at java.lang.Thread.run(Thread.java:536)
    Caused by: javax.ejb.EJBException: null
    Embedded Exception
    null
         at org.jboss.ejb.plugins.BMPPersistenceManager.createEntity(BMPPersistenceManager.java:246)
         at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
         at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:728)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1116)
         at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:257)
         at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
         at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
         at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
         at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
         at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
         ... 19 more
    -- return of create(17, max, [email protected]): null.
    What is my mistake?
    Thanks, Michael

  • CMP Entity Bean with database specific features

    Hi there,
    I�m studying Entity Beans and I'm doing some experiences with SQL Server.
    At first, I built a CMP Bean and marked in deploytool to create the tables. Ok, it worked.
    Now, I'm trying to interact to an existent database. But, I got a problem: the primary key is defined by the Server. I can read it and I can remove entries. But, when I try to insert some entry, I can't pass the key in SQL statement. I edited the generated statement to do it, but it doesn't work. I get a RollbackException.
    My question is: is it possible to do what I'm intending to do with CMP? What am I doing wrong?
    Do you think that, to do this, I should use BMP Entity beans?
    Thanks in advance,
    Anicio

    "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.

  • CMP Entity Beans with custom finders an primary key class

    Hi everybody.
    I've got a Entity with a primary key class and a custom finder. I've defined
    the finder into the xml file like iPlanet's documentation say, but, when I
    try to run the aplication I get the following error:
    Exception: SERVLET-run_failed: Failed in running template:
    /PruebaGI/PruebaGI/pruebagi.jsp, java.lang.ClassCastException:
    com.netscape.server.deployment.SessionBeanDescriptor
    Exception Stack Trace:
    java.lang.ClassCastException:
    com.netscape.server.deployment.SessionBeanDescriptor
    at
    com.netscape.server.servlet.servletrunner.AppInfo.popWebAppDescriptor(Unknow
    n Source)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unknown
    Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJsp
    Compiler(Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri
    (Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri
    RestrictOutput(Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(U
    nknown Source)
    at com.netscape.server.servlet.jsp.JSPRunner.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown
    Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Thread.run(Thread.java:479).
    Could anybody help my? I need to resolve this question quickly.
    Thx
    ..

    Hi Juan,
    Sounds like you've defined either a java.lang.String where it should have
    said Java.util.Vector (or the other way around) in the part of the
    deployment descriptor that defines your custom finder method parameter.
    Regards,
    Raymond
    "Juan Jos� Ayuso" <[email protected]> wrote in message
    news:[email protected]...
    Hi everybody.
    I've got a Entity with a primary key class and a custom finder. I'vedefined
    the finder into the xml file like iPlanet's documentation say, but, when I
    try to run the aplication I get the following error:
    Exception: SERVLET-run_failed: Failed in running template:
    /PruebaGI/PruebaGI/pruebagi.jsp, java.lang.ClassCastException:
    com.netscape.server.deployment.SessionBeanDescriptor
    Exception Stack Trace:
    java.lang.ClassCastException:
    com.netscape.server.deployment.SessionBeanDescriptor
    at
    com.netscape.server.servlet.servletrunner.AppInfo.popWebAppDescriptor(Unknow
    n Source)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    atcom.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unknown
    Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJsp
    Compiler(Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri
    (Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri
    RestrictOutput(Unknown Source)
    at
    com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(U
    nknown Source)
    at com.netscape.server.servlet.jsp.JSPRunner.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    atcom.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown
    Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Thread.run(Thread.java:479).
    Could anybody help my? I need to resolve this question quickly.
    Thx

  • CMP entity beans with netbeans 6.7.1

    package m;
    import javax.ejb.CreateException;
    import javax.ejb.EntityBean;
    import javax.ejb.EntityContext;
    public java.lang.String ejbCreate(java.lang.String key) throws CreateException {
    if (key == null) {
    throw new CreateException("The field \"key\" must not be null");
    // TODO add additional validation code, throw CreateException if data is not valid
    return null;
    public void ejbPostCreate(java.lang.String key) {
    // TODO populate relationships here if appropriate
    public abstract String getUsn();
    public abstract void setUsn(String usn);
    public abstract String getFname();
    public abstract void setFname(String fname);
    public abstract String getLname();
    public abstract void setLname(String lname);
    public abstract String getAddress();
    public abstract void setAddress(String address);
    Hi all.The above code is generated by netbeans 6.7.1. I am using java db and j2ee 1.4. I am new to ejb. All the cmp fields are mapped correctly,but there is no respective ejbcreate() method.Is this the problem of IDE ? Because i have tried the same thing at my friends place who has netbeans 5.0 it worked fine. I changed the method with valid arguments in the beanclass and home interface.But at run time its throwing rollback exception. Please help me.I'm not finding any guide or tutorial to sort out this.Thanks in advance.
    Edited by: M.P on Sep 16, 2009 10:47 AM

    Pretty please, switch to JEE5 if you can. It is so much easier, so much more efficient and far less frustrating. Not only that, but you'll have far more chance of getting help as most people have happily forgotten about the old nightmare specs.

  • 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

  • Using oracle db sequence for auto generating of PKs for CMP entity beans

    Hi,
    I have read quite a number of threads about (auto) generation of keys for primary keys for the CMP entity beans.
    My requirement is I am migrating an application deployed on Weblogic to oc4j. The application is using cmp entity beans with auto key generation using a sequence in the Oracle db. This is specified in weblogic-cmp-rdbms-jar.xml file like below:
    <automatic-key-generation>
    <generator-type>Oracle</generator-type>
    <generator-name>REPUSER.DEPT_REPORT_SEQ</generator-name>
    <key-cache-size>1</key-cache-size>
    </automatic-key-generation>
    In the ejb-jar.xml, it is specified as:
    <prim-key-class>java.lang.Integer</prim-key-class>
    <primkey-field>id</primkey-field>
    Now, I need to migrate this to oc4j. Can somebody suggest me options and clarify my questions kindly?
    1) I have read articles that say that in the ejb-jar.xml, we need to specify <prim-key-class>java.lang.Object</prim-key-class> and this will create a column called 'autoid' in the respective entity table in the Oracle db.
    - How can I use this to assign the value to my primary field, say, id?
    2) Now, with the latest oc4j, can I use Oracle database sequence as the key generator for the values of the PKs just by specifying in the xml descriptor ejb-jar.xml?
    2.a) If yes, is there any article that explains with the code?
    2.b) If no, what are the alternatives I have?
    I have read many discussions that say that we can create a stateless session bean that can lookup the database sequence using simple JDBC call to return the nextval of the sequence. The SSB should be called in the ejbCreate() of the entity bean.
    My related question is, what is recommended for oc4j? What are limitations of the various options for the latest oc4j available?
    How should I go about deploying this kind of ejbs in oc4j?
    Any help and pointers are welcome. Please help.
    Thanks a lot.
    Vadi

    Hello ,
    Instead of exposing a get/set method for each arribute of your bean (corresponding to database table) expose only one object.
    For example
    public class CustomerBean implements javax.ejb.EntityBean{
    private CustomerVO objCustomer;
    private String customerName;
    private String customerMail;
    private String customerType;
    public CustomerVO getCustomer(){
    return this.objCustomer;
    public void setCustomer(CustomerVO objCustomer){
    this.objCustomer = objCustomer;
    public void ejbStore(){
    customerName = objCustomer.getName();
    customerMail = objCustomer.getMail();
    customerType = objCustomer.getType();
    HTH
    VJ

  • Error in deploying CMP Entity Beans

    Hello,
    When I created a CMP Entity Bean using the JDeveloper Release Candidate and try to deploy it I get the following message:
    Auto-creating table: create table POGROUP_PRESS_RELEASE (press_release_id integer not null primary key, press_release_date varchar (255) null, title varchar (255) null, time varchar (255) null, release_type varchar (255) null, URL VARCHAR2(100))
    Warning: Error creating table: ORA-00955: name is already used by an existing object
    What does this mean? Does it mean that this bean cannot be deployed. If the table already exists in the database shouldn't it use the table instead of trying to create the table?
    Any help would be appreciated,
    Gopi

    initialize "table" attribute of <entity-deployment> element to POGROUP_PRESS_RELEASE.This will prevent auto-create functionality of OC4J.
    However this <entity-deployment> tag present only in orion-ejb-jar.xml.So you have to create this file and include along with ejb-jar.xml in jar file.
    Sample orion-ejb-jar.xml looks like this....
    <orion-ejb-jar deployment-version="1.0.2.2" deployment-time="ea013a2eda">
    <enterprise-beans>
    <entity-deployment name="TestHome" location="TestHome" wrapper="TestHome_EntityHomeWrapper5" table="POGROUP_PRESS_RELEASE" data-source="jdbc/OracleDS">
    <primkey-mapping>
    <cmp-field-mapping name="m_ID" persistence-name="ID" />
    </primkey-mapping>
    <resource-ref-mapping name="jdbc/OracleCoreDS" />
    </entity-deployment>
    </enterprise-beans>
    </entity-deployment>
    </orion-ejb-jar>
    For complete DTD :
    http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd
    Hope this helps.....
    --Venky                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • CMP Entity beans using local interfaces

    Why CMP entity beans with CMR relation ship using local interfaces only?
    Why we should not use remote interface to get the CMR field relationship?
    Pls give me the solutions

    "Local interfaces provide the foundation for container-managed relationships among entity beans and session beans. The bean uses the local interface to maintain its references to other beans. For example, an entity bean uses its local interfaces to maintain relationships to other entity beans. Using local interfaces, beans can also expose their state and use pass-by-reference to pass their state between related bean instances. "
    http://java.sun.com/developer/technicalArticles/ebeans/EJB20CMP/

Maybe you are looking for