Using DAO ,TO Pattern without EJB

Hi,
I am developing a web application without EJB. I understand those patterns need not use EJB framework. However, it smees to me that without EJB, the role of TO may be simpler.
In my design, the meaning of TO is to separate the layer between business tier and data access tier. Upon doing some back-end enquiry, the DAO create related TO which can be translate to the business / veiw objects. And the caching will be done on Web tier but not TO layer instead.
Am I right? Would you please give some comments? Thanks a lot.

What is the best way to allow the client to
interact
with Entity objects, without exposing them. ShouldI
implement Value objects that are easily serialized
for transfer across the network?
If you are not using EJB or a distributed
architecture, you do not need DTO's or VO's. They
are an odious construct used to obviate the
shortcomings of remote method calls over anetwork.
I strongly disagree.
They are an obvious and easy model used when the
following characteristics of a system exist.
- Different layers.
- Related data items that are moved throughout the
layers.
- Different usage of the related data items by
different layers.
Yes, I agree. Note the qualification 'if you are not using a distributed architecture'.
None of that has anything to do with remote method
calls over a network. Point of fact the first time I
used them was in a stand alone application with no
network traffic except that needed by the database
driver itself.
Simply create your domain model objects as POJO's
s (plain ole Java objects). Persist and retrieve
your objects via DAO's (data access objects).Your
service layer (facade) will sit on top of thedomain
model, encapsulating method calls into logicalunits
of work.
And how exactly do you move the customer
name/customer address from the DAO to the GUI level?I am assuming the dedicated remoting product the OP specifid, Hessian, will handle moving between the tiers, or at least between the controller/view and the business tier.
- Saish

Similar Messages

  • Struts using DAO Design Pattern ..?Please give an example..... URGENT......

    Dear all,
    I have to develop an application in Struts by using DAO design pattern ..........
    Please give an example on Struts using DAO...................
    Thank you
    Please

    I'm glad you asked. It means Read The Flaming Manual. That'd be the struts manual by the way.

  • Struts using DAO Design Pattern Tutorail

    Can anybody give me a link for the Struts using DAO Design Pattern tutorial
    sample tutorial

    http://javaboutique.internet.com/tutorials/ApacheDAOs/
    Found by using google: strust dao pattern tutorial
    There are more good links using that search...

  • Session Facade Pattern without EJB

    All of the session facade pattern examples that I can find are heavily emphasized on EJB. I am planning on implementing a system without EJB's, and am interested in the advantages of using the Session Facade pattern.
    Are there any good examples of using the Facade pattern outside of EJB to build a java server system? If there aren't, is there a better way to implement this type of strategy in a non-EJB system?

    What is the best way to allow the client to
    interact
    with Entity objects, without exposing them. ShouldI
    implement Value objects that are easily serialized
    for transfer across the network?
    If you are not using EJB or a distributed
    architecture, you do not need DTO's or VO's. They
    are an odious construct used to obviate the
    shortcomings of remote method calls over anetwork.
    I strongly disagree.
    They are an obvious and easy model used when the
    following characteristics of a system exist.
    - Different layers.
    - Related data items that are moved throughout the
    layers.
    - Different usage of the related data items by
    different layers.
    Yes, I agree. Note the qualification 'if you are not using a distributed architecture'.
    None of that has anything to do with remote method
    calls over a network. Point of fact the first time I
    used them was in a stand alone application with no
    network traffic except that needed by the database
    driver itself.
    Simply create your domain model objects as POJO's
    s (plain ole Java objects). Persist and retrieve
    your objects via DAO's (data access objects).Your
    service layer (facade) will sit on top of thedomain
    model, encapsulating method calls into logicalunits
    of work.
    And how exactly do you move the customer
    name/customer address from the DAO to the GUI level?I am assuming the dedicated remoting product the OP specifid, Hessian, will handle moving between the tiers, or at least between the controller/view and the business tier.
    - Saish

  • How to generate report from two tables using DAO design pattern?

    Hi,
    Iam using struts with DAO pattern for my application. According to DAO design im creating model class for each table in my database with getter,setter methods. i have no problem when im generating report from one table. but if have i have to join two tables whatis the better way for doing that? is it good practise to create a new model contains properties from both the tables?
    Please help me
    Thanks in Advance
    Rajesh

    Dear Rajesh,
    As per the pattern you are creating equivalent java objects for every database table under consideration in which each db field will become a private attribute and public getter and setter methods.
    If you have to display data from one table the above approach is sufficient enough.
    But in case your database is normalised ..lets take an example of Bank having Branch and Accounts tables. We dont need to repeat the whole information of the branch for every account in that branch. so we prefer to have a branch id in that table....this approach lot of insertion/deletion/updatation anomlies that may exists with the database...
    now lets come back to our topic....we shall create two java objects 1) Branch 2) Account.....
    When ever u just need to display simple report u can do it staright forward,,,,,now if u want to display branch information along with the account information....the two objects just created are not sufficient
    So i suggest u the following approaches
    1) Create an attribute of type Branch in the Accounts Object......
    This shall serve the purpose of displaying the Btranch information
    2) Create a collection object of type ( Vector or ArrayList) which can have objects of Account in the Branch Object,,,
    Now its upto u how shall u fill up the objects with appropriate sql queries.
    The method that i mentioned is followed by Oracle Toplink and Hibernate ....which provide Object to relation mapping layers.
    Any queries ...revert back to me...
    Mahesh

  • Using DAO without J2EE/EJB

    Can I implement the DAO pattern in my 2-tiered application without using J2EE/EJB? My reason for using DAO is simply to insulate database changes from interface/business code and to make interface/business code easier to write.

    Sure, go ahead.

  • How we can limit the number of concurrent calls to a WCF service without use the Singleton pattern or without do the change in BizTalk Configuration file?

    How can we send only one message to a WCF service at a time? How we can limit the number of concurrent calls to a WCF service without use the Singleton pattern or without do the change in BizTalk Configuration file? Can we do it by Host throttling?

    Hi Pawan,
    You need to use WCF-Custom adapter and add the ServiceThrottlingBehavior service behavior to a WCF-Custom Locations.
    ServiceThrottlingBehavior.MaxConcurrentCalls - Gets or sets a value that specifies the maximum number of messages actively processing across a ServiceHost. The MaxConcurrentCalls property specifies the maximum number of messages actively
    processing across a ServiceHost object. Each channel can have one pending message that does not count against the value of MaxConcurrentCalls until WCF begins to process it.
    Follow MSDN-
    http://msdn.microsoft.com/en-us/library/ee377035%28BTS.10%29.aspx
    http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicethrottlingbehavior.maxconcurrentcalls.aspx
    I hope this helps.
    Rachit
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Anyway to use quartz to schedule jobs without EJB

    Hai all,
    I had a web application in jsp where i need to send automatic mails at regular intervals of time.For this scheduling process i had decided to use quartz. But i had too develop some ejb's for this purpose.As i am using tomcat server it's not possible for me to use EJB's. So is there any other way i can use quartz without ejb's to run a scheduled task?.
    I request your kind help and suggestions in this regard.
    Thank you.

    According to the iPod nano (5th generation) - User Guide you can video tape in landscape or portrait mode. By default, it is oriented in portrait mode (240x376), but due to an accelerometer, automatically switches to landscape mode (376x240) when rotated.
    When I hold the cam vertically, the recorded videos are sometimes in portrait mode with borders but not always. When I hold the cam horizontally (landscape), the recorded videos are always borderless.
    Which way are you holding the camera when you get videos with borders?

  • Use DAO or plain SQL?

    I am building a two-tiered enterprise app with Swing client and RDBMS backend. Over the last two weeks I've tried applying the DAO pattern to my design, manullay creating numerous DTO and DAO classes. I'm now starting to wonder if it's really worth the effort.
    My system is not complicated enough to justify the use of automated OR mapping tools or CMP. Also, the development staff on my team, including myself, have had no expereience in OR mapping and EJB; all we've done in the past involve simple application that accesses the database directly using SQL. We also feel that using SQL directly is adequate in implementing all the functionalities of our system.
    Our initial motivation for implementing DAO was to maximize reuse of persistence code, make code more readable and insulate UI/logic code from change in database schema. But it seems we're now spending too much time thinking about how to map database entities to DTOs, what DAOs to have, what DAO methods to define, etc., whereas in the past to get something from the database we could just write an SQL statement.
    TIA.

    I wouldn't do any application without using DAOs and
    DTOs.
    Perhaps you are focusing to much on the examples
    rather than on the pattern itself. Just because the
    examples do it does not mean that you have to do it.
    You can do with with just one infrustructure class (to
    do the connections, statement, etc) and then the
    following....
    class MyDTO
    public String field1;
    public String field2;
    class MyDAO
    static void create(MyDTO p) {...}
    static void update(MyDTO p) {...}
    static void delete(MyDTO p) {...}
    static MyDTO getById(String id) {...}
    static ArrayList getBySomethingElse(String
    somethingElse) {...}
    }And of course if you don't need one of the above
    methods then do not implement it.i have been doing almost everything in dao but i m not so sure why dtos are so essential, if you write your pojo well, dtos seem to be totally not needed; unless of course you are passing them across networks in ejb systems, and even that, theses days xmls are recommended instead. am i right?
    and lately i havee started using hibernate which i think is great even for small not complecated projects: it does not complicate things, and further, you can still do things in dao with hibernate, i dont see any conficts there: hibernate, jdo are mostly mapping mechnism, and dao is a design pattern.

  • How to use (toplink essentials)JPA with EJB 2.1 spec in oc4j 10.1.3.2

    I have an application that uses EJB 2.1 spec with SLSB (no entity beans) and uses DAO pattern with hibernate2 for persistence. I want to replace hibernate with toplink-essentials (JPA). I cannot upgrade the EJB spec version as we use some thirdparty beans. The application uses DAO pattern so I should be able to hook in a new toplink DAO impl. What I am struggling with is how do I get hold of the EntityManagerFactory in my EJB 2.1 SLSB. Also I need CMT with XA transactions as our application interacts with jms and database using MDBs and SLSBs.
    Prantor

    You should be able to use Persistence.createEntityManagerFactory(<your-persistence-unit-name>, properties), and create your EntityManager from that.
    To have TopLink integrated with JTA, in your persistence.xml (or properties) you need to use a JTA DataSource, and set the ServerPlatform for your JEE server.

  • How I use DAO

    I built a struts application .It is working well.Now I want use DAOand .How I use?
    My struts application :
    Get the input form user and store it in file or datadase. Here I want to use DAO.
    There 6 files .
    They are
    1.inputname.jsp ----------->used for getting input from client.inputs are mail id and password.
    2.GetNameForm.java --------->It is Bean having setter and getter including 2 methods are like filehandler(),dbConnection()(here only implementations).
    dbConnection method just sample i did. From MSAccess database, get Age field and print it in tomcat prompt. Here only i have probs.*What probs that I need to use DAO.
    3.GreetingAction.java ------>It is servlet and I call FormBean Method
    By ((sample.GetNameForm)form).filehandler();
    ((sample.GetNameForm)form).dBConnection();
    String name=((sample.GetNameForm)form).getName();
    String pass=((sample.GetNameForm)form).getPass();
    Thus I called that methods.
    It is good one or Not.
    Note. Both java file under the package name is sample.
    4.greeting.jsp--------> It is output file which is used to expose the output that mail id and password what we gave.
    5.index.jsp---------->It is global forward used to forward client request to inputname.jsp.(It is not a matter to consider with out this file applkication working well.)
    5.struts-config.xml file here only direction controls and mapping items and brief links (we know that).
    package sample;
    import java.io.*;
    import java.sql.*;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    public class GetNameForm extends org.apache.struts.action.ActionForm {
    private String name="";
    private String pass="";
    public GetNameForm() {
    // TODO: Write constructor body
    public void reset(ActionMapping actionMapping, HttpServletRequest request) {
    // TODO: Write method body
    // throw new UnsupportedOperationException("Method not implemented");
    this.name="";
    this.pass="";
    public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
    // TODO: Write method body
    //throw new UnsupportedOperationException("Method not implemented");
    ActionErrors errors=new ActionErrors();
    if( getName() == null || getName().length() < 1 ) {
    errors.add("name",new ActionMessage("error.name.required"));
    // actionMapping.findForward("goInput");
    if( getPass() == null || getPass().length() < 1 ) {
    errors.add("pass",new ActionMessage("error.pass.required"));
    // actionMapping.findForward("goInput");
    return errors;
    public String getName()
    return this.name;
    public void setName(String name)
    this.name=(name==null?"Please Enter The Name":name);
    public String getPass()
    return this.pass;
    public void setPass(String pass)
    this.pass=(pass==null?"Please Enter The ID":pass);
    public void dBConnection()
    Statement st;
    Connection con;
    ResultSet rs;
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(Exception e)
    try
    con=null;
    st=null;
    rs=null;
    con=DriverManager.getConnection("jdbc:odbc:MSACCESSDSN","","");
    st=con.createStatement();
    rs=st.executeQuery("Select * from emp ");
    while(rs.next())
              int a=rs.getInt("Age");
              System.out.println(a);
    catch(Exception e)
    public void filehandler() throws IOException
    String name=getName();
    String pass=getPass();
    //Store the Details of User and Password in File
    Writer output = null;
    try {
    //use buffering
    File testFile = new File("C:\\gandhi\\mail_det.txt");
    BufferedReader input = null;
    input = new BufferedReader( new FileReader(testFile) );
    StringBuffer Contents=new StringBuffer();
    String line=null;
    while (( line = input.readLine()) != null)
    {System.out.println("From the file value=" +line);
          java.util.StringTokenizer st = new java.util.StringTokenizer(line,"@");
          System.out.println("The file contains data:"+Contents.append(line+"\n"));
         /* System.out.println(st.nextToken("@"));
          while (st.hasMoreTokens()) {
                if( st.equals("name") ){
                name="";
                pass="";
    String str=Contents.toString();
    System.out.println("The file Contains"+str);
    output = new BufferedWriter( new FileWriter(testFile) );
    output.write(str+"\n"+name+"\t"+"........."+pass);
    finally {
    //flush and close both "output" and its underlying FileWriter
    if (output != null)
    output.close();
    This is my Bean How I use DAO replace of dBConnection()
    method.
    1.What is important of DAO pls explain me with small codings.
    2.How I use DAO in this coding?
    [Note: I use Exadel StrutsStudio.]
    Anyone have idea pls guide me.

    Well in a DAO pattern you usually have one DAO class for each table in the database so there is for instance one PersonDAO and one ItemDAO which have their respective create, read, update and delete methods. Each DAO also hides its implementation through an interface defining the DAO methods, furthermore there's a DAO factory determining what class to load at runtime. My advice is to start out simple and not too abstract, try looking at the following example - it involves EJBs but explains the pattern.
    http://www.informit.com/guides/printerfriendly.asp?g=java&seqNum=137&rl=1
    Also keep in mind that implementing the DAO pattern using frameworks such as Spring simplifies the process, as illustrated here
    http://www.java2s.com/Code/Java/Hibernate/SpringDaoDemo.htm
    I hope that helps.

  • How can i view and apply new custom patterns without going to preset manager? i had this facility but have now lost it

    how can i view and apply new custom patterns without going to preset manager? i had this facility but have now lost it.  i design patterns but am fairly new to photoshop. i used to be able to click on the drop down menu in patterns in the 'fill' box but cannot now do this.  have i inadvertently clicked on something to turn this facility off?  i now have to go to 'preset manager' and manually move my new design to the first box and click 'done' so that i can use it.

    Which version of photoshop are you using?
    After you define a custom pattern it should be added to the bottom of whatever patterns are already loaded.
    For example, if you define a custom pattern and then go to Edit>Fill>Pattern, the newly defined pattern should have been added to the existing loaded patterns.

  • RE: design patterns involving EJBs and JDO

    Is the idea that you specify in some config file (xml?) the methods of
    your session bean, whether its stateful or stateless, the default bean
    transaction semantics, etc, then say "go" and it generates the home and
    remote interfaces and the skeletal session bean class?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:26 AM
    To: JDO-ListServ
    Subject: Re: design patterns involving EJBs and JDO
    I don't think it's publicly available yet, I used to work there and was
    helping out a little with testing. I'll tell you in advance, it really
    works well. Much like the JDO implementation, the process of turning
    things into SesisonBeans is very transparent to the developer. I guess
    TT is going to make it available in another week or two, as time
    permits.
    ----- Original Message -----
    From: Matthew <mailto:[email protected]> Adams
    To: '[email protected]' <mailto:'[email protected]'>
    Sent: Monday, June 25, 2001 11:18 AM
    Subject: RE: design patterns involving EJBs and JDO
    IMHO, JDO replaces entity beans, but you'll have to decide for yourself.
    My recommendation would be to use session beans exclusively.
    Where do you get TechTrader's "SessionBean Creator"? What are its
    features? How do you use it?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:12 AM
    To: JDO-ListServ
    Subject: design patterns involving EJBs and JDO
    Hi,
    I was just wondering, if you are using JDO for persistence, does it
    matter whether you wrap your objects with proxy EntityBeans or
    SessionBeans? I am currently demoing TechTrader's SessionBean creator,
    which makes means that for me creating SessionBeans is much easier than
    creating EntityBeans. I am currently using stateful SessionBeans to
    wrap the JDO objects, simply dropping them when the bean is passivated
    and refinding them ( they'll already be in the cache ) when the bean is
    activated.
    My main advantage in doing it this way is SessionBeans are so much
    easier to create. Do you see any problems looming, or any other
    advantages to this decision?
    Thanks in advance.
    Eric

    I don't think it's publicly available yet, I used to work there and was
    helping out a little with testing. I'll tell you in advance, it really
    works well. Much like the JDO implementation, the process of turning
    things into SesisonBeans is very transparent to the developer. I guess
    TT is going to make it available in another week or two, as time
    permits.
    ----- Original Message -----_
    From: Matthew <mailto:[email protected]> Adams_
    To: '[email protected]' <mailto:'[email protected]'>
    Sent: Monday, June 25, 2001 11:18 AM
    Subject: RE: design patterns involving EJBs and JDO
    IMHO, JDO replaces entity beans, but you'll have to decide for yourself.
    My recommendation would be to use session beans exclusively.
    Where do you get TechTrader's "SessionBean Creator"? What are its
    features? How do you use it?
    -----Original Message-----
    From: Eric Lindauer [mailto:[email protected]]
    Sent: Monday, June 25, 2001 8:12 AM
    To: JDO-ListServ
    Subject: design patterns involving EJBs and JDO
    Hi,
    I was just wondering, if you are using JDO for persistence, does it
    matter whether you wrap your objects with proxy EntityBeans or
    SessionBeans? I am currently demoing TechTrader's SessionBean creator,
    which makes means that for me creating SessionBeans is much easier than
    creating EntityBeans. I am currently using stateful SessionBeans to
    wrap the JDO objects, simply dropping them when the bean is passivated
    and refinding them ( they'll already be in the cache ) when the bean is
    activated._
    My main advantage in doing it this way is SessionBeans are so much
    easier to create. Do you see any problems looming, or any other
    advantages to this decision?
    Thanks in advance.
    Eric_

  • Is outside-in without EJB's possible?

    Is it possible to create a web service from a wsdl (outside-in approach) without EJB's involved. in CE7.1
    Regards
    ABS

    Yes, you can but manually. There is no such easy tool as for EJBs in NetWever Developer Studio(NWDS).
    Using the the  NWDS  you can generate automaticaly Outside-In  web service sceletons but only with EJB endpoints.
    Maybe you have already read that page:
    http://help.sap.com/saphelp_nwce10/helpdata/en/46/7f2fef88190ad3e10000000a11466f/content.htm
    But if you need a servlet-based web service  and you want to start from the WSDL, you can do it manually by creating a pure java class in web project and than adding the annotations  with values corresponding to the one from the WSDL. In this case you will need some more knowlage in web services area.
    I hope that explainations help you.
    Regards,
    Yulie.

  • Webservice, DAO/Bean Pattern - Help

    All,
    I'm stuck on this one - any help would be much apperciated.
    I'm trying to expose a CFC which uses a DAO/Bean pattern and
    am receiving the following error.
    Could not perform web service invocation "getQuote".
    Here is the fault returned when invoking the web service
    operation:
    AxisFault
    faultCode: {
    http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: coldfusion.xml.rpc.CFCInvocationException:
    [coldfusion.runtime.UndefinedElementException : Element
    QUOTEDAO is undefined in a Java object of type class
    [Ljava.lang.String; referenced as ]
    Here are my files to give you an idea of what I am working
    with.
    /webservices/application.cfm
    /webservices/quote/quote.cfc (bean)
    /webservices/quote/quoteDAO.cfc (my data access object, has
    crud methods)
    /webservices/quote/quoteService.cfc (service layer, i
    generate my wsdl from this)
    I have unit tested the CFC's by running a test.cfm file
    within the /webservices directory which calls all methods. Works
    fine. Additionally, the WSDL generates fine.
    The problem is when I invoke the service, here is how I am
    invoking it.
    <cfinvoke
    webservice="
    http://localhost/apps/webservices/quote/quoteService.cfc?wsdl"
    method="getQuote"
    returnvariable="Quote">
    <cfinvokeargument name="Quote_ID" value="200"/>
    </cfinvoke>
    It's important to note that within my application.cfm I am
    setting up my quoteDAO and quoteGateway objects within my variables
    scope. I am then setting my quoteService in my application scope,
    like so:
    <cfset variables.quoteDAO =
    createObject("component","apps.webservices.quote.quoteDAO").init(variables.dsn)
    />
    <cfset variables.quoteGateway =
    createObject("component","apps.webservices.quote.quoteGateway").init(variables.dsn)
    />
    <cfset application.quoteService =
    createObject("component","apps.webservices.quote.quoteService").init(variables.quoteDAO,
    variables.quoteGateway) />
    I'm not sure what exactly the error I am receiving is, but
    part of me cringes thinking it might have to do with pathing.
    Any advice?

    Simon,
    Thanks for your reply - I modified the code to manually setup
    those objects in my init like so.
    <cfset variables.dsn = "mydsn" />
    <cfset variables.quoteDAO =
    createObject("component","apps.webservices.quote.quoteDAO").init(variables.dsn)
    />
    <cfset variables.quoteGateway =
    createObject("component","apps.webservices.quote.quoteGateway").init(variables.dsn)
    />
    It solved that initial error but now I am getting:
    Could not perform web service invocation "getQuote".
    Here is the fault returned when invoking the web service
    operation:
    AxisFault
    faultCode: {
    http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXParseException: Premature end of
    file.
    faultActor:
    faultNode:
    Any ideas?

Maybe you are looking for

  • Photoshop CS6 freezes upon opening

    Running CS6 64-bit on a Windows 7 machine. Everything is updated, and it was working fine yesterday and every day before for the 2 months we've been running it on this machine. New today: Open Photoshop and it opens the window but you can't click any

  • I have a Aluminium Late 2008, and i want to know if a 1333 RAM works

    Anyone who changed RAM memory from 1066 to 1333?

  • F-44 F-32 residual item exchange rate from invoice

    Hi gurus, When doing clearing we need exchange rate of the residual item gets from choosen invoice. We can get the rate from the invoice but could not change residual item's exchange rate. I have Tried a few BTE's but no result. any user exit,badi or

  • Different purchase order number on each line of billing plan

    Hi I have a problem which I am having difficulty resolving and wondered if there was any way of doing the following. We have many customers who sign a deal with us for an online service. The deal may last for three years, but they are set up on one s

  • List of devices with access to my iMessage?

    Hi, Can anyone tell me where I can see a list of the iOS devices that can access my iMessages? I sold my old 3GS last year and Im pretty sure I did a factory reset but I just want to make sure that phone is no longer associated with my iMessages.