Entity beans and data synchronization

I want to use a BMP to represent information about a database entity where the BMP "fields" are actually statistical summaries (e.g., an Account bean where the "field" num_transactions is calculated using a query rather than stored). I want to do this because the queries that generate the summary statistics are costly and I want to cache the results in memory. Since these are "read-only" statistics, I could use DAOs and a Fast Track Reader but I want to make use of the caching and lookup facilities of J2EE for finding accounts that are already cached.
I only refresh the back end database nightly, so I need to flush all of the values in all cached Account beans nightly. Is there a facility for this type of thing, or do I need to manually control it (e.g., using a "version" number on the data that is checked periodically).
Thx,
John H.

John,
You might also check your application server's documentation. Weblogic provides a read-only entity bean, whereby you can specify a timeout parameter in your descriptor file. The container will then only call ejbLoad() when the ejb is accessed and the timeout has been passed. This, in effect, provides a caching mechanism.
Best of luck,
Richard

Similar Messages

  • 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

  • Entity Beans and Session beans to represet Business lOgic

    How cam we implement Entity Beans and Session beans to represent Business Logic.
    Can anyone explain how can we do this.
    Regards...

    I have session beans calling method in entity beans and any client
    doesn't have access to entity beans, only via session beans.
    If i define security policy and method permissions for session beans
    only, do entity beans use that permissions when calling their methods
    from sessions beans OR should i define the security policy for entity
    beans separately?If you want to set the permission on individual
    methods of entity bean ( with different roles)
    you have to do it separately.
    If you want to delegate the Authenticated user along with
    the method call to the Entity Bean you can use
    run-as-identity-principal.
    For more detail please check out the EJB2.0 Spec.
    -utpal

  • Managed Beans and Data Access Object

    I have a question / need help understanding how to configure backing bean and model objects so that memory and object creation/deletion is done as efficiently as possible.
    1. I have a .jsf page with a form and a commandbutton that submits the form inputs to a backing bean (enrollispbean is backing bean)
    <h:commandButton value="Enter" action="#{enrollispbean.insert}"/>
    2. The backing bean is used for form handling - the insert() method is used to read the data fields from the form and create a SQL string that will be submitted to a model object, DbInsert, that is used as a generic data access object that connects to the database and insert the SQL string:
    public class EnrollIspBean {
    private String beanvar1="";
    private String beanvar2= "";
    // DbInsert is data access object
    private DbInsert dbinsert = new DbInsert();
    public String insert (){
    String sqlstmt;
    sqlstmt = "INSERT INTO ispmain VALUES(beanvar1, beanvar2,..)"
    dbinsert.insert(sqlstmt);
    return "success"; }
    3. DbInsert is the data access object that contains a method, insert(), that accepts a sql string to insert into the database. This method contains the code to obtain a connection from the database connection pool and then execute the sql statement (note: error checking code not shown):
    public class DbInsert {
    public void insert(String sqlstmt) throws SQLException {
    Connection conn = null;
    GetDBConnection getdbconnection = new GetDBConnection();
    PreparedStatement stmt = null;
    conn = getdbconnection.getdbconn();
    stmt = conn.prepareStatement(sqlstmt);
    stmt.executeUpdate();
    stmt.close();
    conn.close();
    return;
    Where I need help understanding is how to set up the scope for the managed beans and data access object. Currently, I have the backing bean within the session scope (using the facesconfig.xml file). My main question is how to set up the scope for the Data Access Object - currently I do not have it as a managed bean within facesconfig.xml. Instead I am creating a new instance within the backing bean:
    private DbInsert dbinsert = new DbInsert();
    Is this the best way to do this? Will the DBInsert object now be tied to the session scope of the backing bean (i.e., when backing bean is deleted, the DbInsert object will be deleted from session scope as well.)
    Ideally I would like the data access object to be available as a shared object throughout the life of the application. When I was programming using a servlet approach, I would have created a servlet to load on startup. Now that I'm using java server faces, I'm confused about the scope / how to efficiently set up a data access object that I want to be available to all backing beans in the application.
    tnanks for any help understanding this.
    Tom

    I was thinking about setting the data access object as application scope so that it can be used by an backing bean to execute sql statements.
    If I do set it as application scope, however, if I do this, do I still need to declare a new instance of the object from within each bean that uses the object?
    For example do I need to declare a new instance of the data access object from within the bean? or, should I assume that there is always an instance of the bean available in the application scope, and if so, how do I reference it from within the bean?
    Bean Code:
    public class EnrollIspBean {
    // DbInsert is data access object
    private DbInsert dbinsert = new DbInsert();
    Finally, I understand performance may be an issue if I have one instance of the data access object available in the application scope - is there a way to make multiple instances available in the application scope?
    thanks

  • EJB entity beans and BC4J

    I have looked at BC4J and it looks good. Buy my question is that isn't this frame work in direct conflict with EJB entity beans. I know lot of stuff that is there in BC4J should have been in EJB enitiy beans, but as a developer why should I go with BC4J and not the standard EJB stuff considering the fact that BC4J is properietery to Oracle?Any thoughts?

    Vimal,
    Without going into exhaustive detail here, I would like to recommend that you take a look at the BC4J Technical White Paper available from the JDeveloper page on OTN (in the 3.0 Technical Information section):
    http://technet.oracle.com/products/jdev/info/techwp20/wp.html
    Amoung other things to note, BC4J is based on pure Java, and is what we consider a 'white box', meaning, you as a developer have complete control over what is going on. You can extend any of the code generated to customize it.
    Primarily though, the major benefit of BC4J is that we have taken care of most of the complicated communication code for you. Communication between the client and the data server, transaction handling, row locking, etc are already written for you. You just use, extend, customize what we have provided.
    In addition, BC4J allows you flexibility in your deployment environment decision. Regardless of where and how you deploy your BC4J Application Module, the client is unchanged.
    Those are the key advantages. Again, for more details, I would take a look at the white paper to see if it more fully addresses your questions.

  • Entity Beans and Caching

    Hi,
    My environment is:
    - Weblogic 5.1 running on Solaris
    - Oracle 8i database server
    - Two physical servers clustered together to form one logical server
    I can possibly upgrade to Weblogic 6 or later if it'll help solve my
    problem.
    Here's what I'm trying to accomplish:
    I want to write entity beans using bean-managed persistence. The BMP
    part of it is strongly preferred because our DBAs like to see and tune
    all of the queries we send from the application.
    In many cases, the data I'm querying is largely static. I want to
    write EJBs that will cache the data in memory and avoid reading it
    from the database server every time the EJB is invoked, unless it
    knows that the data has changed.
    I've done this successfully with single-server installations, but I'm
    not sure how it'll work with a clustered server. Assuming nothing
    outside of my two Weblogic servers is updating my database, can I
    configure the EJB to have exclusive access to the database and count
    on Weblogic to manage the state between the two servers? Or do I have
    to implement some kind of custom signalling scheme so that an EJB in
    one container can notify any EJBs in the other container with the same
    primary key when it has updated the underlying data?
    I know from experience that the container will call the ejbStore()
    method whenever a transaction ends. My usual BMP pattern in the past
    has been to keep track of whether any data has changed during the
    transaction and update only those database columns, if any, that
    actually changed. But I don't think the store method has any way of
    notifying the container as to whether or not it actually stored
    anything; hence, I can't see how the container would know when to
    order the entity bean on the opposite server to reload itself.
    Thanks.

    The 6.1 implements functionality you want:
    http://e-docs.bea.com/wls/docs61/ejb/EJB_environment.html#1121105
    if you use 5.1 you can use this approach:
    http://dima.dhs.org/misc/readOnlyUpdates.html
    Frank LaRosa <[email protected]> wrote:
    Hi,
    My environment is:
    - Weblogic 5.1 running on Solaris
    - Oracle 8i database server
    - Two physical servers clustered together to form one logical server
    I can possibly upgrade to Weblogic 6 or later if it'll help solve my
    problem.
    Here's what I'm trying to accomplish:
    I want to write entity beans using bean-managed persistence. The BMP
    part of it is strongly preferred because our DBAs like to see and tune
    all of the queries we send from the application.
    In many cases, the data I'm querying is largely static. I want to
    write EJBs that will cache the data in memory and avoid reading it
    from the database server every time the EJB is invoked, unless it
    knows that the data has changed.
    I've done this successfully with single-server installations, but I'm
    not sure how it'll work with a clustered server. Assuming nothing
    outside of my two Weblogic servers is updating my database, can I
    configure the EJB to have exclusive access to the database and count
    on Weblogic to manage the state between the two servers? Or do I have
    to implement some kind of custom signalling scheme so that an EJB in
    one container can notify any EJBs in the other container with the same
    primary key when it has updated the underlying data?
    I know from experience that the container will call the ejbStore()
    method whenever a transaction ends. My usual BMP pattern in the past
    has been to keep track of whether any data has changed during the
    transaction and update only those database columns, if any, that
    actually changed. But I don't think the store method has any way of
    notifying the container as to whether or not it actually stored
    anything; hence, I can't see how the container would know when to
    order the entity bean on the opposite server to reload itself.
    Thanks.--
    Dimitri

  • EJB 3.0 entity beans and WebDynpro models

    Hi all,
    first off all my setup:
    WebDynpro Development Component: dcA
    EJB Module Development Component: dcB
    i wan't to create Entity Beans in dcB an use it for my model in dcA.
    My questions:
    1. Why does the "New Wizard" only offer EJB 3.0 Session and Message Beans an no Entity Beans? What is the correct way for creating Entity Beans in DevStudio?
    2. Is ist right that i have to define a public Part containing the Entity Bean to make it visible to dcA?
    Regards,
       Christian

    Hi,
    I'm experiencing same problems, is this a bug or an feature?

  • Read Only entity beans and Finders

    Hi,
    We are using Read Only entity beans with WLS 7.0 SP1 for some entities that represent Reference Data that will never change. What I would like to know is whether WLS needs to hit the database when a finder on these beans is run or does WLS cache the results of the Finder also?
    Thanks.
    Santosh

    Hi,
    we use read only entity beans. It is beneficial if have findByPrimaryKey finders. but we also have finders on non primary key coloumn also. is there a way to cache such local references returned by such non primary key finders also.

  • PDA and data synchronization -help required

    Hi,
    I have experince in developing web applications in jsp/servlets and php. I wish to develop a PDA supported java server
    application. I have downloaded netbeans for using as an IDE. It does have support for mobile emulators, but does not support
    PDA/Palm OS emulators.
    What about IBM websphere and eclipse for using as IDE? Will they support J2ME SDK? Please help me in devoloping my PDA
    application.
    why we use data synchronisation for laptop and PDA for web applications? Why is it not applied in normal PC?
    Thanking in advance,
    From,
    Vinod

    Vinod, you might want to look at the palm.com web site. There is quite alot of information available for developers.
    By reading your original query, I assume you are talking about thread safety and not synchronization, per se. Thread safety is very important in a web app as you surely know. If you don't and have been developing Servlets/JSPs then, hoo boy!

  • Container Managed Entity Beans and Client Identifier in Oracle

    Is it possible to use Container Managed Entity Beans (EJB with CMP)
    in a way that the Oracle database sessions still know the
    individual Client Identifiers of the actual users
    (not just the Identifier of the proxy user defined in the
    Connection Pool)?
    If Yes: How?
    If No: The consequence would be that the
    technologies EJB with CMP cannot be user together with
    Oracle Virtual Private Databases (VPN) because VPN requires
    some kind of Client Identifier.
    I am grateful for any hint.
    Regards,
    Martin Siepmann
    +49 (0)163 / 7765328

    Not quite an auto-incrementing PK, but it is managed by the container. the following is from the turorial
    Generating Primary Key Values
    For some entity beans, the value of a primary key has a meaning for the business entity. For example, in an entity bean that represents a phone call to a support center, the primary key might include a time stamp that indicates when the call was received. But for other beans, the key's value is arbitrary--provided that it's unique. With container-managed persistence, these key values can be generated automatically by the EJB container. To take advantage of this feature, an entity bean must meet these requirements:
    * In the deployment descriptor, the primary key class is defined as a java.lang.Object. The primary key field is not specified.
    * In the home interface, the argument of the findByPrimaryKey method must be a java.lang.Object.
    * In the entity bean class, the return type of the ejbCreate method must be a java.lang.Object.
    In these entity beans, the primary key values are in an internal field that only the EJB container can access. You cannot associate the primary key with a persistent field or any other instance variable. However, you can fetch the bean's primary key by invoking the getPrimaryKey method, and you can locate the bean by invoking its findByPrimaryKey method.
    Maybe that is good enough
    christina

  • Strange behavior with entity beans and servlets in a cluster

    We have 2 WebLogic 4.5.1 servers in a cluster with none of the Service
              Packs installed. When a client uses the deployed entity beans or
              servlets they work every other time. The times they do not work nothing
              happens. No exceptions, no responses to the client ( i.e. HTTP 404s ),
              nothing. I suspect something in the cluster setup since we do not have
              these same problems on non-clustered entity beans or servlets. We have
              made sure all the entity beans have the Shared Database flag set on and
              added the delayUpdatesUntilEndOfTx false to the enviroment of the DD.
              That didn't fix the problem. Any ideas?
              Thanks in advance,
              Dallas Dempsey
              DEM - Houston, TX
              

    Do you have log files?
              - Prasad
              Chris Dempsey wrote:
              > We have 2 WebLogic 4.5.1 servers in a cluster with none of the Service
              > Packs installed. When a client uses the deployed entity beans or
              > servlets they work every other time. The times they do not work nothing
              > happens. No exceptions, no responses to the client ( i.e. HTTP 404s ),
              > nothing. I suspect something in the cluster setup since we do not have
              > these same problems on non-clustered entity beans or servlets. We have
              > made sure all the entity beans have the Shared Database flag set on and
              > added the delayUpdatesUntilEndOfTx false to the enviroment of the DD.
              > That didn't fix the problem. Any ideas?
              >
              > Thanks in advance,
              > Dallas Dempsey
              > DEM - Houston, TX
              

  • Use same transaction in entity-bean and Datasource

    Hello
    I've got following problem. In my stateless container managed transaction Sessionbean i do some inserts and update on my container managed entity bean. In the same transaction I have to read some informations on the database. Some of those informations are already set by the entity bean, but not yet commited. Now I want to read them through a javax.sql.DataSource. But this Datasource doesn't use the same transaction as the session bean.
    Question: Is it possible to let a Datasoucre use the same Transaction as Sessionbean?
    (i work with WSAD 4.0.3)
    Thanks

    Hi,
    You would have to check that you are using an XADataSource instance, instead of a 'regular' DataSource instance (which will not adopt the transaction started by the application server). In particular, the JNDI lookup name of the DataSource should actually point to an instance of XADataSource; a special type for container transactions.
    The administration/deployment tools of the WS will allow you to do that, under Resource Factories or DataSources somewhere.
    Both types look the same towards your application code, so your session bean is probably fine the way it is and does not need rewriting. It is merely in the setup of the WS server that the difference lies.
    Best,
    Guy
    http://www.atomikos.com

  • Cmp Entity Beans and collections

    I am doing a proof of concept application and I have implemented an Entity bean which accesses through a DAO object to my Informix database and returns records based on a serial field called sightID. This works fine and I can access the records and store new records. I now need to demonstrate the power of CMP beans and return a collection showing all records for a particular field called Type. Here is where my problems start. If I am using CMP I need to map the primary key field to the primary key field of the database (this is sightID) the field I need to get the collection on is not a key field and is only a text field with one of four values. How can I use CMP to return a collection based on a non priomary key field? is this possible? I am willing to post all my code but there is 14 pages.
    any help greatly appreciated
    Connie

    EJBQL???..
    SELECT object(o) from table_object 0 where non_primarykey = 'value i want'
    sanjay.

  • CMP Entity Beans and multiple tables

    Hi All,
    Is it possible to have a CMP Entity Bean retrieve attributes from multiple tables
    (using table join), and populate attributes from columns in both tables?
    If yes, how do we configure the same in configuration xml files.
    Is there any special handling required for this in the bean itself?
    Thanks,
    Prabh

    Hi All,
    Is it possible to have a CMP Entity Bean retrieve attributes from multiple tables
    (using table join), and populate attributes from columns in both tables?
    If yes, how do we configure the same in configuration xml files.
    Is there any special handling required for this in the bean itself?
    Thanks,
    Prabh

  • Difference between Data Replication and Data Synchronization?

    Hi Brian: Sorry, the Data Replication task wizard does not support ODBC sources. I don't think there's an easy way to truncate the target tables using a Data Synchronization task, but you should be able to read data from an ODBC source and write it to your target. The main difference between the two task wizards:Data Replication allows you to copy multiple tables from the same source and do incremental loads (only copying new or updated data on subsequent runs of the same task)Data Syncronization allows you to transform data with field expressions and lookups. Cheers,Josh

    I typically use Data Replication where I truncate the target, but it doesn't appear that this works for ODBC connections. However, Data Sync does work for ODBC connections--if I'm already truncating the target, is this the same as a data sync 

Maybe you are looking for

  • My 5s showed an error while updating to ios 8.1 and it has hanged and its not turning on

    my 5s showed an error while updating to ios 8.1 and it has hanged and its not turning on

  • Vendor Return Excise Invoice- VAT/CST

    Dear All, I want to return the material to vendor after invoice verification and before payment. So entered the credit memo, Return material 122 mov type, Create Excise Invoice. Now in my Excise Invoice print format i want CST and VAT to be printed.

  • I would like to buy an Iiphone 5

    I would like to buy an Iiphone 5, but as far as i know in the USA in Apple store I could buy only locked phone,is it true? Or i can also buy neverlock phone there?

  • Will this work with the titanium ? (pic)

    Hey guys planning to buy a new pioneer 89. I want to connect it to my titanium card. so i plan to connect it using analog RCA to mini jack. What I want to know is will the BD/DVD multi in work with the titaniums analog ports?

  • Java(FX) Property Compiler

    Hi! We implemented a small Java(FX) Property Compiler which enables you to use a powerful PropertyHint-annotation. The "compiler" is implemented as an Post-"Java Compiler"-Bytecode-Modification-Tool (using asm-4). Here are 3 small example so you can