Use of DAO Vs StateLessSession bean

Hi,
I have been using the DAO J2EE design pattern for bulk data acces from the database avoiding entity beans,.. But what is happening is that I have factory which creates the instances of DAO's and that factory is used by a Session Facade, I do feel that I can get great benifits of performance of StateLess Session beans if I use Stateless Session beans to access Database as instaces are pooled and Session facade can use another stateless session bean doing the doing bulk data access.
by using Stateless session bean instead of DAO,...do u think I will get better performance
thanks
Jay

Many people will tell you that because EJBs create pools of objects they are faster. However, if you create a DAO with static methods for accessing the data, there are no objects to worry about.
This is really just a design issue.
If you plan to call these Access Methods from one client only, I suggest using statis DAO objects. No overhead, no remote calls, no objects to pool. If you utilize a DataSource or other pooling mechanism, you will be fine. This method is the quickest, however if you later want additional clients to utilize this they will most likely have to provide their own connection and load the DAOs in their own VM.
If you plan to call these Access Methods from more than one client, you may be better off using Stateless Session Beans. The benifit is that all clients will share the DataSource since it is created on the EJB side. The drawback is that your DataBeans (or whatever the EJB returns) must be serializable (unless you use the Local Interfaces) AND the DataBeans have to be serialized, sent over the network and then un-serialized.
If you have time a good middle ground is to implement the EJBs as Local EJBs at first. This allows you to place the DataSource in the EJB tier. Since you will be using Local calls, the serialization and network hit will not be required. This requires as much work as using normal EJBs, but is very close to the speed of static DAOs. If you later need to add remote clients to the mix, simply create the RemoteHome and Remote intefaces. The underlying bean and Local stuff should not be effected. As long as the return objects can be serialized, this will only require and addition to the existing server code with no change to the original (Local based) client code.

Similar Messages

  • Problem  while developing statelesssession bean

    Hi All,
    I am learning Ejb,i developed a simple hello world application using statelesssession bean in weblogic server8.1.And i packed it in a jar file named slb.jar.
    Then i am trying to create stub and skeleton using following command,but i am getting this error.can anybody please help me.
    C:\nkmb\ejb\HelloEjb>java weblogic.ejbc slb.jar
    <Jun 22, 2006 9:55:35 AM EDT> <Warning> <EJB> <BEA-010212> <The EJB 'HelloBean(J
    ar: slb.jar)' contains at least one method without an explicit transaction attri
    bute setting. The default transaction attribute of Supports will be used for the
    following methods: remote[hello()] >
    C:\nkmb\ejb\HelloEjb\ejbcgen\examples\HelloBean_gbyfgg_Impl.java:11: cannot a
    ccess java.io.Serializable
    bad class file: C:\Program Files\Java\jre1.5.0_06\lib\rt.jar(java/io/Serializabl
    e.class)
    class file has wrong version 49.0, should be 48.0
    Please remove or make sure it appears in the correct subdirectory of the classpa
    th.
    public final class HelloBean_gbyfgg_Impl
    ^
    1 error
    Exec failed .. exiting
    can anybody help me to getting out of this problem.
    thanks inadvance,
    nkmb

    http://support.bea.com/application?namespace=askbea&origin=ask_bea_answer.jsp&event=link.view_answer_page_solution&answerpage=solution&page=wlw/S-28139.htm

  • Can i use " this " keyword in session bean.

    Hi,
    I am working with session beans, in my business logic i need to use " this" keyword,
    but is it possible to use " this" keyword in EJB bean?.

    you can.
    do it !

  • Can I use oracle blob by CMP bean in weblogic 6?

    I use weblogic 6.1(sp3) and Jbuilder 7.when I try to use oracle blob by CMP bean,the
    errors are:
    javax.ejb.FinderException: Exception raised in findByPrimaryKey
    java.io.StreamCorruptedException: InputStream does not contain a serialized object
    What should I do?Is there examples about using oracle blob?
    thanks a lot!

    Great! So what was the problem?
    Regards,
    Slava Imeshev
    "Roger Lee" <[email protected]> wrote in message
    news:[email protected]...
    >
    Finally got it working with CMP, which is my preferred choice (over BMP).
    I read the Excel Spreadsheet into a "byte []" array, and the Entity Beanmapped
    "byte []" to the Blob column in the Oracle table.
    "Slava Imeshev" <[email protected]> wrote:
    Roger,
    I'm not quite sure I undestand the problem. Could you:
    1. Post deployment descriptors in part related to this
    CMP bean?
    2. Post the piece of code that is failing?
    Please post the information above and we will help
    you to hunt the problem down.
    No, I don't have any problems accessing blobs
    from CMP.
    Regards,
    Slava Imeshev
    "Roger Lee" <[email protected]> wrote in message
    news:[email protected]...
    Yes. I have added;
    <dbms_column-type>OracleBlob</dbms-column-type>
    It fails because the locater to the blob, obtained by findBYPrimaryKeyis
    null.
    i.e. an empty_blob() is not created.
    Have you got CMP to access Blobs in WLS 6.1?
    "Slava Imeshev" <[email protected]> wrote:
    Hi Roger,
    Have you tried using OracleBlob as dbms-column-type?
    Also, could you post that part of your code that is failing?
    Regards,
    Slava Imeshev
    "Roger Lee" <[email protected]> wrote in message
    news:[email protected]...
    I can access Clobs using CMP. If you are using the Oracle OCI Driveryou
    do not
    need to add this line.
    However if you are using the Oracle Type 4 Thin drivers you need
    to
    add;
    <dbms_column-type>OracleClob</dbms-column-type>
    to the file;
    weblogic-cmp-rdbms-jar-xml
    This DOES NOT work with Blobs.
    I am unable to get WebLogic 6.1 sp4 persist a Blob to an Oracle
    8.1.x
    table and
    retrieve it using either CMP or BMP.
    Unless any one show me a complete working CMP and BMP example?
    Roger Lee
    Deepak Vohra <[email protected]> wrote:
    BLOB and CLOB DBMS Column Support for the Oracle DBMS
    http://edocs.bea.com/wls/docs61/ejb/cmp.html#1061636
    shybird wrote:
    I use weblogic 6.1(sp3) and Jbuilder 7.when I try to use oracle
    blob
    by CMP bean,the
    errors are:
    javax.ejb.FinderException: Exception raised in findByPrimaryKey
    java.io.StreamCorruptedException: InputStream does not contain
    a
    serialized
    object
    What should I do?Is there examples about using oracle blob?
    thanks a lot!

  • Using weblogic repository of message beans

    Hi,
    Using weblogic repository of message beans
    This is possible?

    Hi Steve,
    I don't know what you need UOO for, but, for some use cases, its sufficient just to configure a default UOO on the sender's connection factory.
    Propapagation of a UOO from one desitnation to another is not automatic (except via SAF, or unless OSB somehow does it for you). Plain vanilla JMS apps do this by calling msg.getStringProperty("JMS_BEA_UnitOfOrder") on the received message and setUnitOfOrder() on the javax.jms.WLProducer.
    You might find that there's more OSB expertise on an OSB newsgroup (I think it's one of the newsgroups under [url http://forums.oracle.com/forums/category.jspa?categoryID=194]SOA & Process Management).
    Regards,
    Tom

  • ADF JSF, refresh collection using a DAO without a database - Best Practice?

    I have previously developed a comprehensive application using ADF 10.12. This application did not use a database, instead I was manually populating collections of objects that data controls were generated for to talk to the ADF components.
    This applciation was based upon the old (10.12) version of ADF and utilised the following structure;
    DataPage (start.jsp) --> DataAction (getRecords) --> DataPage (display.jsp)
    In this instance, by overriding methods on the getRecords DataAction I could populate the collection that was to be displayed on the display.jsp DataPage.
    I am now designing a new application that will hopefully use the latest version of ADF (10.13). This application will also use collections of objects from an external source.
    The structure of ADF 10.13 (faces-config.xml) is different to 10.12 (struts-config.xml) e.g.
    JSFPage (start.jsp) --> getResults (navigation case) --> JSFPage (display.jsp)
    Having read the ADF Developer Guide, and looked through example #60 (onPageLoad) that was developed by Steve Muench, I am aware that there are at least three options that I could use to get populate the collection of objects that are displayed on the display.jsp page when a button is pressed on the start.jsp page;
    1. use a backing bean that extends PageController
    2. use a backing bean that extends PagePhaseListener
    3. use a backing bean that has a specific action that is assigned to the button
    Q1a. which one is the most appropriate/efficient to use?
    When the button is pressed on the start.jsp page, it will be set to call getResults navigation case on faces-config.xml.
    Q1b. Is it possible to detect when this action is triggered, populate the collection of data which is bound the display.jsp JSFPage, and then allow the getResults navigation case to continue execution?
    The application that I am developing will have the following structure;
    recordObject - Object to hold a record
    recordCollection - Collection of recordObjects
    recordDao - DAO use to populate the recordCollection
    When using 10.12 I did not have a separate recordDao (as it was query only) I had a refresh method within the recordCollection.
    Q2. what is the most efficient way of achieving this? there will be one DAO per Collection and approx 30 Collections
    Q3. does anyone have/can point me in the direction of any other examples where actions that trigger call navigation cases are overriden, custom actions are called and then the original ones allowed to continue?
    Thanks in advance for your help/advice
    David

    Thanks for the pointers Steve, they have been very useful.
    This is what I have done;
    set up the following pages and navigation cases (show in bold) on faces-config.
    start.jsp >> getSystems >> systems.jsp >> display >> display.jsp
    systems.jsp >> new >> new.jsp
    systems.jsp << back << new.jsp
    added refreshCollection() as a button to start.jsp
    set the button to call getSystems
    added the collection as a read only table to systems.jsp
    - this works correctly
    added the collection as an input form to the new.jsp page
    added the addNewRecord(systemObject so) function as a button to new.jsp
    set the button to call back
    - this is where I encounter a problem.
    The addNewRecord(systemObject so) function takes a new record as a parameter and adds it to the collection. It is doing this but it is not populating the new record. I know that this is the case because when I return to the systems.jsp page there is a new record within the table but it is empty.
    Q. How do I capture the values from the input form that is on the new.jsp page, set them to a new instance of an object and then pass this object to the addNewRecord(systemObject so) function?
    Thanks
    David

  • Invoking DAO from session bean

    Hi,
    I have a session bean method "method1" that invokes a DAO method which reads/write to DB2 database table. Will the DAO's db interaction will be part of the transaction initiated by container which is defined at the session bean's method ?
    If yes, then will the transaction manager put a lock on the db record till the excution of the method is completed(transaction has a method scope), though the db read(DAO invocation) is at the beginning of the method ?

    Thanks for your reply. But why do you feel that the container is not responsible for putting the lock as we set the transaction isolation level setting at the method level ?
    The following problem led me to post my original question :
    I have an application which used to run on WAS 5.0 and DB2 ver 7 patch 6 . I put a patch 10a for the DB2 drivers. After that I am getting problem executing a particular scenario. The scenario is - I have a stateless session bean method which updates a db record by invoking the an entity bean (CMP) and then accesses the same record through a DAO. But the read fails as the db record is locked. The session bean method has a transaction attribute "TX_REQUIRED". As both the db operations are part of the same transaction, I fail to understand why there should be lock on db record for the second operation ?
    Do you have any clue ?

  • Plaese  HELP  JAVA DEVELOPER DAO and ENTITY BEAN

    WHEN DO WE USE ENTITY BEAN INSTEAD OF DAO

    Generally DAO's are used with Stateless Session beans where the transactions may involve in different query executions. We go for Entity beans for persistence.

  • How to use value returned from a bean in jsp page

    Hi All,
    I have a string array value being returned from a javabean to a jsp page. I want to be able to assign the value to a variable in the jsp page.
    How do I do this?
    Many thanks :)

    thanks for your response.
    I actually used something like this:
    <% String loggedin = log.User(user,password);
    out.println(loggedin);
    %>i am not yet as much of an expert on beans as i would like to be, but i thought it is not really a bean if it has a getter method which takes arguments?

  • Using EL variable in struts bean:message tag(not struts EL tag)

    Is there any work around to use an EL variable inside struts bean:message tag as key:
    I have like this:
    <bean:message key="${bean.keyName}"/>
    which is throwing error , I know this can be resolved by using struts-el tags but i cannot use them for specific reasons.
    I dont want to use bean:define tag to define my 'bean' and then use like this:
    <bean:message key="<%=bean.getKeyName%>"/> (this actually works, but i want to use EL variable)
    Is there any work around to use EL variable and make the message display on the jsp.
    i tried multiple ways like scriplets and jsp:useBean but nothing worked, Please let me know..
    Thanks in advance

    Im pretty sure that EL does not work in the normal struts tag unless its struts-el tag.Have you tried it?
    As I said, in a properly configured JSP2.0 container you can use EL expressions anywhere you could traditionally use a standard runtime expression <%= expr %>.
    What server are you using? What JSP version?
    The Struts-el tags were written so that you could use EL with struts in JSP1.2 containers.
    The c_rt tags were written so you could use runtime expressions with JSTL tags in JSP1.2 containers. Their use was discouraged even then. Now I consider their use absolutely unnecessary.
    Please read this thread: http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0
    Cheers,
    evnafets

  • Using variable in Payload Zip Bean

    Hi to everyone, in my scenario I'm using receiver file adpater to create a zip file with payload and its attachment using Payload zip bean Module.
    In the parameter Transform.ContentType I insert:text/xml;name = 'test.xml' for the payload and text/xml;name = 'test.txt' for the attachment.
    I would zip theese files keeping their orinal file name, so is it possible to use the variable %filename% that contains the name of the message interface, or also the original file name?
    Thank's in advance for your help.
    Anassap_XI.

    Hi,
    Please check :
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
    You find more information about the PayloadZipBean in SAP note 965256.
    *Pls: Reward points if helpful*
    Regards,
    Jyoti

  • Using javascript to clear up beans

    i am using a jsp page that calls a java bean to connect to a database and run a query,
    is it possible to use javascript to do a clear up on the java when the window is closed?
    cheers

    IOW, you shouldn't be passing an open connection to the view. Package up your query results in a bean and send that to the view, instead.

  • JDeveloper, ADF, Quartz: Quartz Using different Classpath than Backing bean

    Hi,
    I have an ADF 10g application. When i get an Application module using Configuration.createRootApplicationModule, it works fine in normal java class or backing bean.
    Now i have an quartz configured in this project. The same code does not work in Quartz Job class.
    When i print the classpath using System.getProperty("java.class.path") in normal java class or backing bean, then it considers everything along with BC4J jar files. But when i print the same thing in quartz job, it has only two jar files inside its class path: C:\JDeveloper\j2ee\home\oc4j.jar;C:\JDeveloper\jdev\lib\jdev-oc4j-embedded.jar.
    Can anyone let me know what could be the issue if someone has configured Quartz with JDeveloper and ADF application.
    --Chintan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi!
    Have you solved this problem? If yes, can you share the solution.
    Regrads,
    Sašo

  • How to use special aggregation in bi  beans

    Dear Gurus:
    I am using Bi beans in a project, on cube has a banlance measure, I set the last() aggregation in olap option with OEM, But when I query this cube, this measure still use default sum(), So whould you please help me how to use this special aggregation in bi beans.

    George,
    One way to get non-additive aggregations is to use an Analytic Workspace, or AW. AWs support all the aggregation operations, and can be exposed through the OLAP Catalog as "fully solved" cubes, in which case
    the OLAP API will merely fetch the correctly computed aggregate values.
    Today, setting up an AW for use by BI Beans and the OLAP API requires lengthy scripts that create the necessary ADTs and Views, plus calls to the CWM2 PL/SQL API. However, OLAP will be releasing an AW Manager tool
    that makes this process easier. Please contact OLAP Product Management for further details.

  • Using Composite keys in Entity Beans

    Hi, I am trying to develop a test application with two entity beans, (1) OrderBean (key is a string called order_no) and (2) LineBean (key is order_no and an integer line_no) using CMP 2.0. Relationship between OrderBean to LineBean is 1 to many. I created a primary key class for LineBean called, LinePK with both order_no and line_no as the public members. My home interface for LineBean has the following three finder methods:
    public java.lang.Object findByPrimaryKey(LinePK lkey);
    public Collection findByOrder(String order_no);
    public Collection findByProduct(String product_id);
    I could provide sql for the OrderBean which has only one field(order_no) as primary key, but I don't know how to code appropriate SQL for the finder methods of LineBean involving a user defined primary key class (in my case LinePK with order_no and line_no). I am trying to deploy this application in J2EE RI server, but getting deployment errors saying invalid return types for the finder methods. In the deploytool I provided the primary key class for LineBean as java.lang.Object with no primary key field name. Any help in this matter with sample sql code is greatly appreciated. Thanks !!!

    Some things to consider:
    - Your findByPrimaryKey in the Remote interface needs to have the remote interface as return type
    - The implementation of the finder needs to have your primary key class as return type
    - If you're using CMP 2.0, you need to specify the search criteria as EJB QL
    Using CMP 2.0, you don't code findByPrimaryKey at all, all you need is the EJB QL for findByOrder/findByProduct in the deployment descriptor. The EJB QL for findByOrder would look like:
    select Object o from Line where o.order_no = ?1If you use BMP, you would code the findByPrimaryKey implementation like this:
    public LinePK ejbFindByPrimaryKey(LinePK pk) throws FinderException {
      String sql = "select order_no from line_table where line_no=? and order_no=?";
      InitialContext ic = new InitialContext();
      Object obj = ic.lookup("datasourcename");
      DataSource ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class);
      Connection conn = ds.getConnection();
      try {
        PreparedStatement stmt = conn.prepareStatement(sql);
        try {
          stmt.setInteger(1, pk.line_no);
          stmt.setInteger(2, pk.order_no);
          ResultSet rs = stmt.executeQuery();
          if (!rs.next())
            throw new ObjectNotFoundException("not found: " + order_no + "." + line_no);
          return pk;
        finally {
          stmt.close();
      finally {
        conn.close();

Maybe you are looking for

  • Acrobat pdf 9.0 has stopped working

    Hi I recently upgraded to CS4 and Quark 8. Yesterday my Q8 files were happily printing out using Acrobat pdf 9 (and had resolved an irritation in 8 where no files including the character '/' would print). Today every file I try to print gets stopped

  • Console errors (multiple, 60-some) -- "value of separation out of range"

    I have a long, 128 page chapter. I was getting a "font not found, substitute Times New Roman for MS Shell Dlg 2" console message when I opened the file. An online search turned up the suggestion that if you can't actually find the font in your doc, t

  • Creating previews in LR3

    Hi, Yesterday I installed LR3 on my Mac (10.6). I then imported my entire library and LR3 joyfully started creating previews. Since LR still uses only 2 cores apparently (nobody at Adobe has passed the exam on concurrent programming yet it seems), I

  • Output via firewire with studio 2

    I have recently set up a FCP Studio 2 system with a kona LHe card and am having a hard time outputing to dvd. We are using an HD player deck (JH-3) and our analog outputs from the kona are component only. DVD players only take s-video and composite.

  • HT4009 why i cant purchase in apps???

    before 1/4/2013 is ok de... same app but now cant purchase in apps https://itunes.apple.com/my/app/luan-shi-xiao-xiong-xin-ban/id578170345?mt=8 tis apps...