CMP entity bean update after database update

I'm new to JDeveloper and J2EE. Since JDev 10.1.3 is now production software I finally got started with it. Everything was quite simple to achieve however I have one problem.
My current setup is faily easy. I have a statelss session bean and a CMP entity bean using TopLink (both EJB 2.1). Getting them both created went smooth and having the two talk was as easy as pie thanks to Jdev.
The problem I have is with the entity bean. I'm using a custom finder method to retrieve records using non-PK fields. This works like a charm and I'm getting the data I need. But when I update the data in the database (OracleXE) and I rerun the client I get the old data. The only way for me to get new data is to restart the embedded OC4J server in JDev.
How can I have the entity bean updated by changes in the database?

Thanks Avi!
I spent some time with the documentation and I see I can configure the cache. However how to do this is not clear to me. I have the impression that most of it relates to BMP entity beans.
Apparantly there is a DoNotCheckCache method I can invoke on the query, but I have no idea how to achieve this...
Message was edited by:
Deddiekoel

Similar Messages

  • Use direct JDBC with CMP entity bean in one transaction

    I am trying to use direct JDBC call with CMP entity bean within a session
    bean method that requires transaction. The problem is that it appears these
    are not in the same transaction. When I use the JDBC call, the CMP entity
    bean update to the DB has not been committed yet.
    We are using Weblogic 5.1 SP6. The DB is Oracle.
    What I do for the JDBC is get a new connection from the pool using weblogic
    jdbc pool driver.
    Any help would be appreciated.
    Patrick

    Hi. You can do JDBC and invoke CMP EJBs and have this all treated
    as one transaction, if your hand-written code explicitly starts
    a JTS transaction, then uses the jts driver or a TxDataSource to
    get the JDBC connection. Then your code can call transactional
    EJBs and their work will be included in the transaction you started.
    Assuming the bean work went OK, and your manual JDBC went OK, you
    can manually commit the UserTransaction at that time. This is 5.1
    talk. For 6.0, with @PC, this may be even easier...
    Joe
    Patrick Shen wrote:
    >
    But if I do that, then they would not be in the same transaction anymore.
    Is there any way to use JDBC with CMP Entity bean in the same transaction?
    Patrick
    "L'artiste" <[email protected]> wrote in message
    news:[email protected]...
    Are you calling all the CMP create in the session Bean ? If so, beforeyou
    make the JDBC call from the session bean, the CMP in 2. should commit. Try
    to set its attribute to TX_REQUIRES_NEW. This way, the calling client will
    block until this transaction is done (committed) before the execution
    continues. There might be some overhead involved in doing so if you are
    anticipating a lot of users.
    "Patrick Shen" <[email protected]> wrote in message
    news:[email protected]...
    What I am trying to do is:
    In a Session bean method -
    1. create a new CMP entity bean (a new row in DB table)
    2. create another new CMP entity bean that uses previous bean as foreignkey
    3. use JDBC to update the row just created
    And all these 3 calls have to be in one transaction.
    Thanks,
    Patrick
    "L'artiste" <[email protected]> wrote in message
    news:[email protected]...
    Can you give a little bit more information?
    Do you have methods in your session bean that creates this CMP entitybeans?
    It looks like
    you might wanna try to change the isolation level to
    TRANSACTION_READ_COMITTED
    to preven dirty_read.
    "Patrick Shen" <[email protected]> wrote in message
    news:[email protected]...
    I am trying to use direct JDBC call with CMP entity bean within a
    session
    bean method that requires transaction. The problem is that it
    appears
    these
    are not in the same transaction. When I use the JDBC call, the CMP
    entity
    bean update to the DB has not been committed yet.
    We are using Weblogic 5.1 SP6. The DB is Oracle.
    What I do for the JDBC is get a new connection from the pool usingweblogic
    jdbc pool driver.
    Any help would be appreciated.
    Patrick
    PS: Folks: BEA WebLogic is expanding rapidly, with both entry and advanced positions
    for people who want to work with Java, XML, SOAP and E-Commerce infrastructure products.
    We have jobs at Nashua NH, Liberty Corner NJ, San Francisco and San Jose CA.
    Send resumes to [email protected]

  • CMP Entity Beans read database row twice?

    Here are two basic questions regarding container managed persistence Entity Beans:
    How many database read operations are performed when a remote reference to a CMP Entity Bean is obtained by a client?
    Is it correct, that each row is read twice?
    For example if a have one row in a database which I want to lookup, AFAIK first the findByPrimaryKey method perfoms a select to lookup the primary key, and then the (container-)ejbLoad method actually reads the row a second time to populate the CMP fields of the bean.
    And how often are UPDATE statements performed?
    Is a database UPDATE statement performed each time a setXX method is invoked?
    Thanks for any help,
    Robert

    How many database read operations are performed when a
    remote reference to a CMP Entity Bean is obtained by a
    client?
    Is it correct, that each row is read twice?It all depends on the CMP system. A simple system might well hit the database twice, once to validate the primary key and once to load the object's fields. A
    smarter system might try to cache the results from the first, so it didn't need to do the second (although this might be a bit dodgy from a transactional point of view).
    However, a couple of facts about databases come in here. Firstly, the query to check the primary key doesn't actually need to load any data from the table: it just needs to check that the key exists. Thus, it should be possible to handle this query just using the index, not touching the table itself at all. Secondly, databases do their own caching, so if a row was loaded in the first query, there is a good chance that it would still be around for the second.
    And how often are UPDATE statements performed?
    Is a database UPDATE statement performed each time a
    setXX method is invoked?Under CMP 1.1, UPDATES are typically done at the end of a transaction; if you use container-demarcated transactions, then yes, UPDATES will happen after every call. If the client code sets up its own transaction, then the UPDATE will only happen after several setXXX calls.
    This can be a performance problem. A common solution is the use of coarse-grained detail objects:
    http://java.sun.com/j2ee/blueprints/sample_application/model/ (section 10.4.1.2)

  • 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

  • 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

  • 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

  • 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's problem with MS-SQL Server 2000

    Hi everyone!
    I have a problem regarding CMP Entity Bean on OC4J.
    I made one CMP Entity Bean and deployed it to OC4J.
    It was successful.
    I used MS-SQL Server 2000 as Datasource.
    So, I installed MS-SQL Server's JDBC Driver and add some jar files to classpath.
    And I updated 'data-sources.xml' in OC4J's config directory.
    Then, I updated also 'orion-ejb-jar.xml' in my application's directory.
    I changed data-source's name to my data-source's name which use MS-SQL Server 2000.
    Finally, I started OC4J and EJB Client program which called Enitiy Bean's create method.
    But, The error occured which was 'Database error: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]LINE 1: '.' Wrong sentence'.
    What's wrong? I need any helps.
    Here is stack overflow message. Thank you. Best regards.
    com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: Database error: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]LINE 1: '.' Wrong sentence.
         at UserHome_EntityHomeWrapper2.create(UserHome_EntityHomeWrapper2.java:1114)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:80)
         at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
    at connection to localhost/127.0.0.1 as admin
         at com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMIConnection.java:1530)
         at com.evermind.server.rmi.RMIConnection.invokeMethod(RMIConnection.java:1453)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:53)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:22)
         at __Proxy0.create(Unknown Source)
         at com.emc.ksc.ejb.user.UserBeanTestClient1.create(UserBeanTestClient1.java:73)
         at com.emc.ksc.ejb.user.UserBeanTestClient1.<init>(UserBeanTestClient1.java:49)
         at com.emc.ksc.ejb.user.UserBeanTestClient1.main(UserBeanTestClient1.java:1077)

    Hi Young,
    From the information you have supplied, my guess is that the SQL
    string that OC4J is sending to SQL-Server is incorrect. So it may
    help if you could see the exact SQL string. In order to see the
    SQL string, I suggest you either run OC4J in "debug" mode, or try
    using "P6 Spy".
    The following web page has details on running OC4J in "debug" mode:
    http://kb.atlassian.com/content/atlassian/howto/orionproperties.jsp
    And here is the web page for "P6 Spy"
    http://www.provision6.com/
    And these other web sites may also be of help (in general):
    http://www.orionserver.com
    http://www.orionsupport.com
    http://www.atlassian.com
    http://www.elephantwalker.com
    Good Luck,
    Avi.

  • How to use same transaction when calling CMP entity beans and  DAO (JDBC)

    We are currently using Weblogic 8.1 SP2 with an Oracle 10g database (using XA thin and non-XA drivers).
    We have a session bean that invokes an entity bean and a DAO (data access object pattern) in order to add data in 2 separate tables (account and history). Rows are added to the first (account) table using a CMP Entity bean while inserts are done in the 2nd (history) table using a DAO. Here is some pseudo code:
    addHistorySessionBean (trans-attribute="Required")
    begin
    Step #1 - call addAccountEntityBean (trans- attribute="Required")
    Step #2 - call addHistoryDAO (get datasource, connection)
    end
    The 2nd table (history) has a foreign key constraint to ensure that the corresponding key exists in the first (account) table. Unfortunately, DAO inserts on the 2nd (history) table fail with a foreign key constraint violation (INTEGRITY CONSTRAINT VIOLATION - PARENT KEY NOT FOUND!) since they cannot see the row added to the 1st (account) table in step #1 by the CMP entity bean.
    How does one ensure that all this is done in a single transaction ? It appears that the app server creates two seperate transactions (one for the session bean facade and the entity bean and a 2nd transaction (when we retrieve a connection using the same data source JNDI name) for the DAO.
    A post on server side suggested using a "<resource-ref>" in the session bean to tie the two potentially separate transactions together, but that does not work for us. However, I am not sure if we are doing that correctly. After we define the resource ref in the session facade bean, do we use the resource ref "name" attribute to lookup the datasource or do we still lookup the datasource by JNDI name ? Do we need to define the resource-ref tag in the entity bean also ?
    Does Weblogic allow using a single transaction for this type of a scenario ? How does one specify within Weblogic that the same transaction should be utilized by the entity bean and any subsequent DAOs?
    People have also suggested that we defer constraint checking until the transaction(s) are committed but that sounds like a work acount without addressing this issue. Would postponing the constraint checking in Oracle cause any additional overhead ?
    Any suggestions with specific examples or documentation on how to address this issue will be gratefully appreciated.

    Thanks for your suggestion. Unfortunately, this does not work since it appears that there are 2 separate transactions going on here. One, the original one initiated by the session bean and used by the entity bean and the other initiated by the DAO. Any other ideas appreciated.
    Hi,
    Try setting the delay-database-inserts tag to
    ejbCreate in RDBMS descriptor file.
    http://bernal/stage/wls/docs81/ejb/DDreference-cmp-jar
    .html#1113981
    vasanthi ramesh

  • 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

  • Catching SQLException in CMP Entity Bean

    I wana catch an SQLException which is raised while updating a record in DB through a CMP Entity bean method (violating a Foriegn key constraint). It throws to the client a RemoteException which contains a RollbackException which further contains an EJBException and finally it contains the required SQLException. The containment of exceptions is like RemoteException contains RollbackException contains EJBException contains SQLException.
    I know I can parse out the SQLException, but what if I wana know that which foriegn key constraint raised this excepton while updation.
    I'm naive in EJB's and I hope the forum will not turn down my trivial question.
    Regards
    Rana

    For example I have a table "Emplyee" having a field key "DeptID", "DeptID" is a foriegn key from table Department.
    I have a user interface which can update "Employee" table and another user interface for updating "Departments" table. I can try to update employee A's "DeptID" to 3 whereas somebody else has deleted "DeptID" 3 from the "Department" table, this results in a foriegn key constraint violation at DB level. Now I wana catch this exception and report it to the client that the updation was not successful. How I can catch this exception.
    The current situation is that the container throws a RemoteException. This RemoteException contains the following nested hierarchy of exceptions
    RollbackException>> EJBException>> SQLException.
    At client side I'm not sure which exception caused the RemoteException until and unless I can find the Deepest exception (SQLException in this case) in the nested hierarchy.
    How I can write the code for handling exception as RemoteException from the container can be in the result of many other Exceptions as well.
    Regards
    Rana

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

  • Problem when trying to delete CMP entity bean

    Hi,
    When I try to remove a CMP entity bean, I have this error :
    re09.projet_ejb.syndic.AdminException: Exception thrown from bean; nested exception is: javax.ejb.EJBException: nested exception is: com.sun.jdo.api.persistence.support.JDOUnsupportedOptionException: JDO76207: Update of a primary key field is not allowed.It's only happening when I try to remove a bean which has a relation with another bean. The relation type is One to Many. I tried to search on this forum to find an answer but I found nothing that could help me.
    Message was edited by:
    Starship
    Sry I just found the mistake, the cascade delete was not on the right place :s
    Message was edited by:
    Starship

    Got it sorted so I thought I would share the solution here:  The problem wasnt related to LR 5.2 but was to do with Mac OS X 10.8.5 AKA Mountain Lion.  I had also noticed that I was having an issue around deleting anything on my MAC.  When I tried to delete a file from anywhere I was asked to submit my password.  The message I got was finder wants to make a change please submit password.  I checked through the mountain Lion forums and found a solution here; https://discussions.apple.com/message/20499360#20499360%2320499360
    I implemented it and the problem has dissappeared.

  • Re: Using CMP Entity Beans in Business Logic

    One thing that you need to answer here is
    "In the queries for the subsequent tables, in the where clause will the fields be the same and is it that only their values change?"
    In the above is true I'd suggest going for a CMP as you save a lot of coding and transaction management out there.
    If the above is not true and even the fields in the where clause change on fly there is no way that you can go for CMP. You will have to go for BMP.
    Hope this helps decide

    Hi.
    You might try posting this message to the weblogic.developer.interest.cmp
    newsgroup.
    Regards,
    Michael
    Pankaj wrote:
    Hi,
    I have made a few CMP entity beans which are mapped to single tables in
    Oracle 8i.
    Create and remove of a row is working fine via the entity bean.
    But when i try to update a particular row it is not happening.
    The steps that I am doing are :
    1. call home.findByPrimaryKey(instance of the Primary key class)
    2. remote.setXXX for the field to be modified.
    when i invoke setXXX() method the methods are called in the following
    sequence : ejbLoad() > setXXX() > ejbStore()
    but the data is not getting persisted in the Data base ....in the column it
    is still the same old data.
    is it something to do with a commit call or some configuration issue??....
    Is there any other step to be called
    I am using Weblogic 6.1 Sp2
    Any help will be appreciated....This is really urgent...
    Thank you,
    Pankaj--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • 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]

Maybe you are looking for