Business Objects(BOs) & Data Transfer Objects(DTOs)-both needed ?

In a J2EE system...
I know that "Business Objects" (BOs) are basically value objects (VOs) ...lots of getters and setters and some business logic. These are basically to model nouns in the system. Eg Student BO.
I know that "Data Transfer Objects" (DTOs) are value objects (VOs)....with getters and setters... with the purpose of avoiding multiple method calls...to avoid overhead...which effects performance. eg it's better to pass a Student DTO then say...pass the student ID and student name and student age etc etc.
Main question : Should a system have both ? If yes, why do I need a StudentBO.java and then another StudentDTO.java....when they are so similar ?...when both are basically VOs ? Can't I just use BOs to serve as DTOs ?
Thanks.

Hi,
I've started using BO's and DTO's since 3 months .With my experiece i understand we nned both of them.
The BusinessObject represents the data client. It is the object that requires access to the data source to obtain and store data.
DTO
This represents a Transfer Object used as a data carrier. The DataAccessObject may use a Transfer Object to return data to the client. The DataAccessObject may also receive the data from the client in a Transfer Object to update the data in the data source.
From this i want to tell you that We are not gonna do any operation on BO's but we do operations on DTO
Ashwin

Similar Messages

  • Is it mandatory to use Business object for data transfer and work flow?

    <font size="3">
    <pre>
    In our enterprise projects we deal with some screens where we add or update some data and again
    we retrieve that data and display to user in various ways like displaying on screen as
    a report or viewing in excel etc.. Most of the times, though we identify the business objects
    based on the nouns in requirements document, really while implementing there will not be any
    business logic in the objects. Almost all the objects which we identfy as business objects
    may have methods like add, delete, update and retrieve methods. Still in these cases, is it required to
    have business objects or can we use transfer object to send the data for saving and retriving or any other
    pattern/guideline is there for dealing such cases?
    I really appreciate your comments on this topic.
    Also I apologize ahead of time if my explanation is not clear to you.
    </pre>
    </font>
    <p>
    Thanks in advance.
    <p>
    Regards,
    <p>
    Rizwan.

    In my opinion, DAO pattern would be suitable for you. Generally the DAO (Data Access Object) will have the CRUD (create, read, update, delete) methods to retrieve data from data-source (e.g. database). Based on the data it will create the DTOs (Data Transfer Objects) and pass them to the caller. It will also receive the DTOs from the caller and save it the data-source. Thus in your case you can
    - remove the CRUD methods from the Business Objects (BO) and make them pure DTOs and use them with DAOs (If you are using JDBC codes inside your application and you don't have much of validation or processing logic in your BOs).
    http://www.corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm
    OR
    - use BOs in combination in DAOs (if using the database connection from a pool and BOs are having complicated processing logic).
    http://www.corej2eepatterns.com/Patterns2ndEd/BusinessObject.htm

  • Data Transfer Objects

    Is it safe to assume that Data Transfer Objects should be populated by Business Objects that are local to entity beans or whatever is being used to populate them?

    jschell wrote:
    ttb999 wrote:
    jschell wrote:
    So if the point of DTOs is to reduce network traffic, why would you initially populate them using a remote object? That doesn't have anything to do with what I said.Well that was the jist of my question.Your statement has a historical perspective which probably doesn't mean much in current DTO usage.
    Originally RMI was promoted as a a 'method' interface. As such you would have had the equivalent of a DTO with setter/getter for each attribute. Each setter/getter would invoke a remote procedure call to the server.
    Thus a data object with 5 attributes would cause 5 network calls to 'populate' the attributes.
    That was vastly inefficient.
    Consequently the first DTO type (which was not called a DTO) was promoted as a way to avoid that.
    If you want you can look up "Remote Procedure Call" (RPC) which would have been the origin of where the 'method' idiom originated.And quite apart from performance, populating a local object from the remote prevents disruption of the local data in case the network connection is (temporarilly) lost.

  • Hierarchical data transfer objects confusing Flex compiler...

    I just posted this same query on FlexCoders... but then I
    thought this might be a better target group to ask, so here goes:
    We are working on a set of data transfer objects where we
    have matching server-side java classes and client-side AS classes.
    Some of these DTO contain lists of other DTOs. As an example:
    A.java:
    public class A {
    List<B> blist
    In A.as we have...
    class A {
    public var blist : ArrayCollection;
    And we have B.java and B.as
    Then we have a RemoteObject call to pull down a bunch of A
    objects....
    Here's the problem, Flex does not compile B.as at build-time.
    So if B.as has a compiler problem, you never know about it,
    except that the 'blist' in A never gets populated. If you break
    down the data transfer and debug it. You find that during
    RemoteObject call, the blist data comes "down the wire", but as an
    ArrayCollection generic Objects, they never get turned into
    instances of Bs...
    I am guessing that this is happening because at compile time,
    there is not direct reference to B in the clientside project. Our
    covering .mxml wants one or more A objects, and inside A the blist
    is an ArrayCollection. So the compiler doesn't see a reference to
    B..
    So anyone know how we can fairly seamlessly make sure B.as
    gets compiled at build time so we'd know of compiler issues with it
    rather than spending lots of time debugging mysterious null values?
    (This appears to happen whether the project is set to compile
    on the client-side or the server-side. We are using Flex and FDS
    2.0.1 and Java 1.5)

    up...

  • Simple Question - Data Transfer Object

    Hey gurus,
    I like the option in JBuilder to automatically create Data Transfer Objects and an Assembler for it. But what? I used to make the assembler a Session Bean, and JBuilder makes it a normal Java class with static methods. I know JBuilder always ships with the best solutions, but...
    what is the advantage of the static class here? And in my case, i have the session beans and the entity beans deployed on a different server, would that make a difference for the advantage?
    greets,
    Nick.

    Hey gurus,
    I like the option in JBuilder to automatically create
    Data Transfer Objects and an Assembler for it. But
    what? I used to make the assembler a Session Bean,
    and JBuilder makes it a normal Java class with static
    methods. I know JBuilder always ships with the best
    solutions, but...
    well....... not always
    :-)

  • Data Transfer Object Class

    HI, i'm new with the web dynpro,  so i been told to use java web dynpro  using the Data Transfer Object, with a conection to Oracle.
    anybody has information about the web dynpro using Data Transfer Object.
    thanks in advance!!

    Hi,
    Their are lot of articles on the same here, please search for java bean models. Will give some hints
    I guess what you are planning to do is
    DB--> EJB/POJO--
    > Webdynpro
    Regards
    Ayyapparaj

  • User-Defined Data Type (Data Transfer Objects) is null

    hi
    i try to access a nested complex datatype over blazeds. i always see that the second level of the  complex datatye is NULL but the other data's like String are ok.
    here an example:
    as you can see TT1 has a member TT2, and a String
    TT2 has a member TT3 and a string
    and TT3 has just a string.
    in the ActionScript the TT2 referenz in TT1 is always NULL.
    Java Code
    Java code:
    package clientreportingserver;
    public class TT1 {
        public String getT1s() {
            return t1s;
        public void setT1s(String t1s) {
            this.t1s = t1s;
        String t1s;
        public TT2 getTt2() {
             return tt2;
        public void setTt2(TT2 tt2) {
             this.tt2 = tt2;
        TT2 tt2;
    =================================================
    package clientreportingserver;
    public class TT2 {
        public String getT2s() {
            return t2s;
        public void setT2s(String t2s) {
            this.t2s = t2s;
        String t2s;
        public TT3 getTt3() {
             return tt3;
        public void setTt3(TT3 tt3) {
             this.tt3 = tt3;
        TT3 tt3;
    =================================================
    package clientreportingserver;
    public class TT3 {
         public String getT3s() {
            return t3s;
        public void setT3s(String t3s) {
            this.t3s = t3s;
        String  t3s;
    ActionScript DataType
    package clientreporting.model
    import mx.collections.ArrayCollection;
    [RemoteClass(alias="clientreportingserver.TT1")]
    [Bindable]
    public class TT1
        public var t1s:String;
        public var t2:TT2
    ====================================================================
    package clientreporting.model
    import mx.collections.ArrayCollection;
    [RemoteClass(alias="clientreportingserver.TT2")]
    [Bindable]
    public class TT2
        public var t2s:String;
        public var t2:TT3
    ===================================================================
    package clientreporting.model
    import mx.collections.ArrayCollection;
    [RemoteClass(alias="clientreportingapi.TT3")]
    [Bindable]
    public class TT3
        public var t3s:String;
    here the output from blazeds. for me it looks perfect, all data are transmitted
    BlazeDs output
    [BlazeDS]Deserializing AMF/HTTP request
    Version: 3
      (Message #0 targetURI=null, responseURI=/5)
        (Array #0)
          [0] = (Typed Object #0 'flex.messaging.messages.RemotingMessage')
            source = null
            operation = "getTT"
            destination = "exposedServiceWrapper"
            clientId = "E57066B1-170E-503A-D4EC-004166E95FC3"
            body = (Array #1)
            timeToLive = 0
            headers = (Object #2)
              DSEndpoint = "channel-amf"
              DSId = "E570490A-C218-4A29-4229-8CD6F29222FC"
            timestamp = 0
            messageId = "5FDB47AD-9066-DD95-4CD4-0CE0D3F6C337"
    [BlazeDS]Adapter 'java-object' called 'null.getTT(java.util.Arrays$ArrayList (Collection size:0)
    [BlazeDS]Result: 'clientreportingserver.TT1
      t1s = TT 1 String
      tt2 = clientreportingserver.TT2
        t2s = TT 2 String
        tt3 = clientreportingserver.TT3
          t3s = TT 3 String
    [BlazeDS]Serializing AMF/HTTP response
    Version: 3
      (Message #0 targetURI=/5/onResult, responseURI=)
        (Externalizable Object #0 'DSK')
          (Typed Object #1 'clientreportingserver.TT1')
            t1s = "TT 1 String"
            tt2 = (Typed Object #2 'clientreportingserver.TT2')
              t2s = "TT 2 String"
              tt3 = (Typed Object #3 'clientreportingserver.TT3')
                t3s = "TT 3 String"
    1.262936445958E12
    (Byte Array #4, Length 16)
    (Byte Array #5, Length 16)
    (Byte Array #6, Length 16)
    the last Alert (accessing t2) got always a null pointer, the fist Alert works fine and print out the string i expected to see
    call in ActionScript
        public function loadTT():void {
           _policyService.getTT(loadTTHandle);
        private function loadTTHandle(content:TT1):void {
           Alert.show("" + content.t1s);
           Alert.show("" + content.t2.t2s);
    is it possible to access a nested complex type? i only could find simple examples.
    thanks for your help joe

    I found the problem
    in the flashlog.txt i found :ReferenceError: Error #1056: Cannot create property AFoo on [...]
    this let me to this blog http://blog.comtaste.com/java/  ==>
    Automating  ActionScript 3 classes generation from Java Beans in a LiveCycle Data Services context
    it was a naming problem.

  • Can I declare arraylists in data transfer object

    Can I use arraylists in data transfer objects

    Yes, and don't double post:
    http://forum.java.sun.com/thread.jsp?thread=540027&forum=425&message=2616354
    Answers don't always come in three minutes. Be patient.

  • Data Transfer Objects Design Pattern

    Hi All,
    Could anyone tell me more about this DTO design pattern, as such when one should prefer it.
    Second is this pattern transaction safe or one would have to implement the same manually. Any updates would prove benefecial to me.

    Hi
    I do not understand what you mean.
    A dto is just an object which you populate in one layer and use in another layer.
    you do not need any jndi look for DTO , instead you lookup for ejbs , datasources ,....
    for example you lookup for some CMP , search and find some CMPs , populate DTO with those CMP and send the DTO to front layer.
    if it is not the answer , can you explain more about your requirements(S)

  • Flex - Java Data transfer objects. How do you usually work ? (Brainstorming)

    Hi,
    I would like to explain you how I work and to know how you guys do.
    All this discussion is just an example of how I work. I really want to know how other coders usually work. This way, maybe I can improve my code.
    I would like to know how do you do when you want to retreive data into typed objects when these data contains reference to other typed objects.
    Here is how I always work :
    I want to retreive all my customers into a flex datagrid and to display all information.
    Here is my Customer table structure (just an example)
    id, name, refCompany, refLanguage, refCountry, refCustomerGroup
    refCompany, refLanguage, refCountry, refCustomerGroup are IDs that reference to other tables.
    To ensure to retreive all data into typed object, I make a Customer,Company, Language, Country, CustomerGroup, Flex and Java classes.
    I make a query that looks like : Select * from Customer
    My java code will looks like :
    List<Customer> customers = new ArrayList<Customer>;
    ResultSet rs = myConn.execSelect(query);
    while(rs.next)
         customers.add(new Customer(rs))
    return customers;
    In my Customer class, I have a constuctor that takes a resultSet
    My customer class contains variables (refCompany that is actually a Company object (not an id), refLanguage that is actually a Language object (not an id),... )
    Customer(ResultSet rs)
         this.name = rs.getString("name")
         this.refCompany = new Company.findById(rs.getInt("refCompany"))     //This function returns a Company object
         this.refLanguage = new Language.findById(rs.getInt("refLanguage"))     // This function returns a Language object
    Here is how I always do. I don't know if it is a good way because for each customer found in the database, I will make 4 queries (4 findById to find each object : company, language, country, customerGroup of the current customer).
    But this way is generic, I don't have to make a specific query that will retreive all objects in one time. I select all customers, and in the constructor I select all objects that I have the reference...
    The big problem with this way is when I retreive objects, I always retreive all referenced objects and I do not necessarily want it.
    What do you think about the way I work ? How you guys do ? what is the best practice ?

    up...

  • Adobe Flex + PHP (Using Data Transfer Object pattern in amf)

    hello
    i'am using amf to connect my flex application to the php back end,but i want to use DTO(DataTransferObject), i haven't enough info about this pattern.
    can you introduce me a reference or have you any suggestion?
    thanks for your attention
    Uniqe_max (amin shahnazary)

    here is another way of doing it
    http://www.youtube.com/watch?v=1n1uHQAP18Q
    http://www.youtube.com/watch?v=fQsCBk9tvkQ

  • Error -10006 can't set object or data to object or data

    Hi
    Tripped up again by a silly error, I am trying to update an item in a record list but keep getting error -10006
    Code below simplified but still produces the error, all help gratefully received.
    set filePath to "/Users/Ours/Documents/Text File.txt"
    set recordList to every paragraph of (read filePath) -- get all records
    set AppleScript's text item delimiters to ","
    set (text item 1 of item 1 of recordList) to "Ninth"
    message is :
    tell current application
      read "/Users/Ours/Documents/Text File.txt"
      --> "First,Second,Third
    Result:
    error "Can’t set text item 1 of \"First,Second,Third\" to \"Ninth\"." number -10006 from text item 1 of "First,Second,Third"

    You can't set text items directly like that. first convert the text to a list of text items, alter the list, then convert it back to text:
    set filePath to "/Users/Ours/Documents/Text File.txt"
    set recordList to every paragraph of (read filePath) -- get all records
    set {oldTID, AppleScript's text item delimiters} to {my text item delimiters, ","}
    set tempList to text items of recordList
    set item 1 of tempList to "Ninth"
    set recordList to tempList as text
    set AppleScript's text item delimiters to oldTID

  • When I upgrade from OS10.5.8 to Snow Leopard will all my data transfer.  If I need to back up what is the best way to do this?

    I plan to upgrade from OS10.5.8 to Snow Leopard. Will all my data, applications and settings transfer automatically?
    If I need to back up what is the best way to do this?

    If everything works perfectly, your data should not be touched.
    Personally I never trust my data to everything working perfectly.
    I always backup everything twice at least.

  • Error while Transfer Object

    Hi,
    I have a Data-Transfer-Object which is transfered between a client and an EJB. While this transfer I get this exception:
    java.rmi.MarshalException: CORBA MARSHAL 1398079699 Maybe; nested exception is:
         org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : Mismatched serialization UIDs : Source (Rep. IDRMI:com.tsystems.ik.to.BANFTO:0000000000000000) = 0000000000000000 whereas Target (Rep. ID RMI:com.tsystems.ik.to.BANFTO:5F16928AAE9F82C6:70F941F18AA0F040) = 70F941F18AA0F040 vmcid: SUN minor code: 211 completed: Maybe
    Any ideas, where the error is?
    My DTO:
    import java.io.Serializable;
    public class BANFTO implements Serializable {
    private String number;
    private String name;
    public BANFTO (){}
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    public String getNumber() {
    return number;
    public void setNumber(String number) {
    this.number = number;

    I had the same problem.
    I deleted automatically generated deployment and RMIC code, did a rebuild all projects, deployed on server, restarted server and it just worked out.

  • Where to put logic with Transfer Objects?

    I'm playing with Transfer Objects for the first time, and have got this one class I'm not sure how to design the Transfer Object for. The problem is that I have some logic that is needed by both the domain model and by the client.
    The class is named Moment. It's basically a wrapper around the java.util.Calendar class because I don't like passing objects of that type around in my code. That Calendar class is just to complicated to expose everywhere.
    So, an easy example is that internally, Moment stores time in millitary time. I need a method that will take an hour, a minute, and AM or PM and convert it to millitary time for storing internally in the Moment.
    Before Transfer Objects, this was easy enough of a decision. Moment had several factory methods called makeMoment. One of these took three arguments: hour, minute, and AM or PM. And, it internally converted to millitary time and stored the time in the Moment. However, now that the client is operating on Transfer Objects and not Domain Objects, if I put that method on Moment in the domain model, it won't be available to the client. If the client takes user input in AM/PM format from the user, it would have to duplicate logic already implemented in the model.
    Options I think I have:
    1.) Put the conversion method in MomentTO, maybe make it static. Then, my Moment class calls this method on MomentTO to do the coversion. This would work, but it seems funny to have the domain model calling business logic inside the Transfer objects.
    A variation of this solution is just whenever my domain model wants to create a Moment, have it first create a MomentTO via a factory method that could do the coversion, and pass the MomentTO to a Moment constructor. This seems even funnier though to have the domain model creating Transfer Objects for internal use. It just seems to me that the point of Transfer Objects is to export information about the domain model to the client, leaving a lot of the specifics behind. Not something that the domain model uses for processing internally.
    I could put the conversion method on the MomentTO and just say anybody who wants to create a Moment using anything but millitary time is going to come from the client that will be using Transfer Objects. Nobody else will be creating moments using anything but straight millitary time. But, this approach seems inflexible.
    2.) Make a separate library / package that is available to both the domain model and the client. The inital reason I don't like this solution include the fact that I don't need much more other logic to be shared like this, so this package would be really, really small.
    Any suggestions? Just can't seem to find something that makes good sense. I do have several other things like this for this Moment class in creating a Transfer Object for it. But, it is just this one class that I'm having this problem with.

    >>
    If this is for the pursuit of knowledge, then thatis
    all well and good. However, if you actually wantto
    do something with this application, I wouldrecommend
    the following link:
    http://xp.c2.com/YouArentGonnaNeedIt.html
    - SaishI think you missed the part in the thread where I'm
    not seeing the evil of Transfer Objects. Please
    explain. They really don't seem that much work to
    develop to me.
    Fair enough. However, my point is that any time you develop something that 'might' be needed is time you are taking away from time developing things that 'are' needed.
    One of the listed advantages of the Transfer Object
    pattern in the Core J2EE Patterns is hiding
    complexities of the domain model from the client.
    This seems to be very handy for my application.The session facade pattern would accomplish the same effect.
    . Many of the domain model objects are versioned,
    but the first three iterations of development that I
    want to complete before deployment need to know
    nothing about the versions. With transfer objects,
    this can all be safely hidden in the Application
    Service objects.
    I fail to see how transfer objects themselves would not require versioning or modification. Given a large enough transfer in the domain model, it woud be difficult to insulate an associated transfer object. Granted, these changes may occur less frequently.
    Plus, I'm trying to figure out how the hell Commons
    Validator works with Spring. Really wish I could
    find a getting started guide. What I've found so far
    makes it look like it's going to be easier to
    validate Transfer objects than my domain model
    objects, because all the validated fields will be on
    one object. Not mostly on one object with some
    fields scattered about like they would be with domain
    model objects...I've found good FAQ and HOW-TO documentation at Jakarta while working on several Commons projects, including Log4J and FileUpload. Validator has no such online documentation?
    For Spring, I recommend the new Johnson "J2EE Development with Spring" and (I forget the author) "Spring in Action".
    - Saish

Maybe you are looking for