Value Object Pattern - Does EJB 2.0 Deprecate?

In the EJB 1.1 specification, there were no such things as Local Interfaces and Local Home Interfaces. In the Core J2EE Patterns book, they cite the main reason for using the Value Object Pattern as being a way to avoid much of the network overhead associated with using EJB; any call to an EJB potentially involves a remote call to the object even if it lives in the same JVM. But with EJB 2.0 you can have a Local Interface which seems to eliminate all this network overhead already.
Anyone care to register an opinion on whether or not there are still valid reasons for implementing the Value Object Pattern when using EJB 2.0?
Any input would be greatly appreciated!

Yes - the fact that it's generally a bad idea to "tie" stateful information (e.g. EntityBeans) to a stateless front-end.
In other words, it's better functionality to transfer "static" sets of data (Value Objects) in chunks from a business-layer (SLSBs, fronting the EntityBeans) than to have the front-end directly query the persistence tier. Also, using the Facade (and related) patterns as the go-between the view (front-end) layer and the persistence layer, you gain the flexibility of the persistence (and the business) layer changing without having to re-engineer the view at all.

Similar Messages

  • Value Object pattern implementation problem

    Hi All!
    I try to implement value object pattern in my bean as follows:
    /* Simplified code */
    public class Value implements Serializable {
    private String s;
    public setS(String value){
    s = value
    public getS(){return s}
    bean class:
    public class Bean extends Value implemets EntityBean {
    public Value getValue(){return this}
    Now question.
    When I try run this code I get next message
    org.omg.CORBA.MARSHAL: minor code: 0 completed: No
    org.omg.CORBA.portable.InputStream com.visigenic.vbroker.orb.GiopStubDelegate.invoke(org.omg.CORBA.Object, org.omg.CORBA.portable.OutputStream, org.omg.CORBA.StringHolder, org.omg.CORBA.Context, org.omg.CORBA.ContextList)
    org.omg.CORBA.portable.InputStream com.visigenic.vbroker.orb.GiopStubDelegate.invoke(org.omg.CORBA.Object, org.omg.CORBA.portable.OutputStream, org.omg.CORBA.StringHolder)
    org.omg.CORBA.portable.InputStream com.inprise.vbroker.CORBA.portable.ObjectImpl._invoke(org.omg.CORBA.portable.OutputStream, org.omg.CORBA.StringHolder)
    com.retailpro.cms.common.InventoryValue com.retailpro.cms.ejb._st_Inventory.getValue()
    void com.retailpro.cms.inventory.SetInventory._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    void oracle.jsp.runtime.HttpJsp.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
    void oracle.jsp.app.JspApplication.dispatchRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    void oracle.jsp.JspServlet.doDispatch(oracle.jsp.app.JspRequestContext)
    void oracle.jsp.JspServlet.internalService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    void oracle.jsp.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    void javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
    void oracle.lite.web.JupServlet.service(oracle.lite.web.JupRequest, oracle.lite.web.JupResponse)
    void oracle.lite.web.MimeServletHandler.handle(oracle.lite.web.JupApplication, java.lang.String, int, oracle.lite.web.JupRequest, oracle.lite.web.JupResponse)
    void oracle.lite.web.JupApplication.service(oracle.lite.web.JupRequest, oracle.lite.web.JupResponse)
    void oracle.lite.web.JupHandler.handle(oracle.lite.web.JupRequest, oracle.lite.web.JupResponse)
    void oracle.lite.web.HTTPServer.process(oracle.lite.web.JupRequest, oracle.lite.web.JupResponse)
    boolean oracle.lite.web.HTTPServer.handleRequest(oracle.lite.web.JupInputStream, oracle.lite.web.JupOutputStream)
    boolean oracle.lite.web.JupServer.handle(oracle.lite.web.JupInputStream, oracle.lite.web.JupOutputStream)
    void oracle.lite.web.SocketListener.process(java.net.Socket)
    void oracle.lite.web.SocketListener$ReqHandler.run()
    Seems like object can't be serialized.
    But when I change my getValue() to next
    public Value getValue(){
    Value result = new Value();
    result.setS(s);
    return result;
    Everything goes fine!
    Can anybody comments this situation?
    Any information will be appreciated!
    Mike
    null

    Have you tried using our Business Components for Java framework to assist in developing your EJB components. BC4J is a design pattern framework that implements the J2EE Blueprints design patterns out of the box:
    [list][*]Session-Entity Fagade
    [*]Paged-List
    [*]Unified Data Access & Logic
    [*]Value Object
    [*]Model View Controller
    [list]
    and more...
    So many things you don't have to code yourself when you use BC4J to turbocharge your development... Also, using BC4J insulates you from having to choose once and for all at the beginning of your project that you ARE USING EJB AT ALL COSTS on your project.
    Many projects discover that they don't require a distributed objects configuration, but end up paying for it in architectural complexity and EJB's assumption that all beans might be located on remote VM's.
    With BC4J, you can build an app, deploy to EJB if you need EJB for a given project, or deploy to CORBA, or just to simple Java classes for improved performance without the remoting overheads. All without touching your application code.
    Pretty cool, I think. But of course, I'm biased :-)
    Steve Muench
    Lead Product Manager for BC4J and Lead XML Evangelist, Oracle Corp
    Author, Building Oracle XML Applications

  • BusinessDelegate and Value Object Patterns

    I have just embarked on the facinating world of J2EE. My questions are very simple:
    Why would I use a BusinessDelegate pattern? What is it and why have this extra tier?
    Finally, why would I use a Value Object? What are they? How would I use them in practice?
    As you can see I am a total novice and would appreciate expert advice. Thanks in advance.

    Why would I use a BusinessDelegate pattern? What is it
    and why have this extra tier?Well, there are always some extra "plumbing" work involved when calling business services, especially if they are located in remotely hosted EJBs. You need to create your JNDI-context, perform a lookup, do narrow()-operations etc. etc.
    Now this is implementation-specific stuff, that your presentation tier doesn't really need. No, it's only concerned about sending some values to the business-logic tier, and retrieving the results and acting upon them (usually formatting and displaying them to the end-user at some way).
    If you wouldn't have BusinessDelegate as an extra insulation layer between your presentation and business tiers, you'd end up cluttering your presentation code with unnecesessary implementation-specific stuff. When you have a BusinessDelegate, you can isolate all the dirty work into it, make it configurable somehow, and just call it from your Servlets/JSPs/Applets whatever.
    So instead of this:
    InitialContext ctx = new InitialContext();
    Object home = ctx.lookup( "com.company.myproject.ejb.FirstBusinessBean" );
    FirstBusinessBeanHome narrowedHome = (FirstBusinessBeanHome)PortableRemoteObject.narrow( home, FirstBusinessBeanHome.class );
    FirstBusinessBean remote = home.create();
    // Only now you get down to the real business.
    String[] initialValues = remote.readInitialValues();
    // And so on.
    // Some stuff like try..catch suppressed for readability.You can do something simple as this:
    EJBDelegate myDelegate = EJBDelegate.getInstance( MyBeans.FIRST_BUSINESS_BEAN );
    String[] initialValues = myDelegate.readInitialValues();
    Finally, why would I use a Value Object? What are
    they? How would I use them in practice?A value object is an object whose sole purpose is to represent a value (or a bunch of values). In the previous example, if you needed to get a list of persons from you database, and one person is represented as one entity bean, at first you'd probably end up getting a collection of PersonEntityBean's remote interfaces as a result of some ejbFindBy()-query method.
    Now if you are running on a true distributed enviroment, when you iterate through this collection, displaying the persons ie. on a JSP page, every getFirstName(), getLastName(), getTitle() etc. call could potentially be a remote method call, adding a tremendous amount of extra overhead. This of course depends entirely upon your app servers implementation.
    But if you replace your Remote interfaces with a simple Value object, for example PersonVO, it could be as simple as this:
    public class PersonVO
        String firstName, lastName, title;
        public PersonVO( String firstName, String lastName, String title )
            this.firstName = firstName;
            this.lastName = lastName;
            this.title = title;
       public void getFirstName() { return this.firstName; }
       public void getLastName() { return this.lastName; }
       public void getTitle() { return this.title; }
    }Instead of a collection of remote interfaces, you return these from your business method, and use them for displaying in your presentation logic. Simple, clean and fast.
    Oh, and notice that the VO is immutable. This is a done on purpose.
    Another point where a VO is really helpful that if you have ie. two different tables in your DB, represented by two different Entity Beans (Person and PhoneNumber for example), which have a relation at the database. With a VO, you can package data from multiple entities into a single object, instead of having to deal with a multitude of different entities and their remote interfaces.
    I could go on for hours about this, but I guess I'll have to do some productive work as well. Anyway, these patterns are tried and tested, any believe me, they make the job a lot easier when properly implemented.
    .P.

  • Returning more than one value/object from an EJB method

    Hi,
    I have the follong method in the remote interface of my EJB:
    void createSomeObject( MyObject obj1, List returnList1, Map returnMap1);
    Since i want to return a List (returnList1) and a Map(returnMap1) from my EJB method "createSomeObjects", i am passing these as parameters thinking they will be passed by reference and the client(servlet) gets the changes the EJB made to these objects.
    But it doesn't seem to be working, the EJB is filling the List and Map objects and the servlet doesn't get it (pass by value problem).
    My understading is that, all parameters to an EJBs are passed by value(because they are remote calls, the RMI thing), let me know if this right.
    Is there any workaround apart from the following alternative?
    Alternatives:
    1. Wrap "List list1" and "Map map1" in another model and return this instead of passing them as parameters.
    Thanks
    Vasu

    My understading is that, all parameters to an EJBs
    are passed by value(because they are remote calls,
    the RMI thing), let me know if this right.Yes, that is correct - which you should know from your introduction to J2EE reading.
    Is there any workaround apart from the following
    alternative?
    Alternatives:
    1. Wrap "List list1" and "Map map1" in another model
    and return this instead of passing them as
    parameters.No.

  • Inserting a tree of value objects

    Let's say I have these entities in my database:
    Person
    personId (PK)
    firstName
    lastName
    PhoneNumber
    phoneNumberId (PK)
    number
    description
    personId (FK referencing Person entity)
    I have a PersonValueObject class with the following attributes:
    Integer personId
    String firstName
    String lastName
    Collection phoneNumbers (a collection of PhoneNumberValueObject's - can be populated or set to null, depending on use case)
    I have a PhoneNumberValueObject class with the following attributes:
    Integer phoneNumberId
    String number
    Strong description
    Integer personId
    PersonValueObject person (can be populated or set to null, depending on the use case)
    I have session facade with the following methods
    createPerson(PersonValueObject personVO)
    createPhoneNumber(PhoneNumberValueObject phoneNumberVO)
    My question is, how should I insert a tree containing a Person and his related PhoneNumbers? I see three options:
    1) The session facade's client calls createPerson(), which inserts the personVO and then the session facade traverses the personVO.phoneNumbers collection and calls createPhoneNumber() internally for every element in the collection. This means that the createPerson() method must have extra code to traverse the collection.
    2) The session facade's client calls createPerson(), which inserts the personVO. Next, the session facade's client traverses the personVO.phoneNumbers collection and calls createPhoneNumber() for every element in the collection. This means that the client must have extra code to traverse the collection.
    3) Add a third method called createPersonTree(PersonValueObject personVO), which internally calls createPerson() and then internally calls createPhoneNumber(). In this case, the createPersonTree() method must have the extra code to traverse the collection. The way I see it, the advantage of this approach is that the session facade's client has a choice of calling createPersonTree(), if it needs to insert a whole tree, whereas it can just call createPhoneNumber() directly if it just needs to add a new phone number to an existing person.
    Comments?

    1) Are you using session Bean for inserting the data?
    2) Are you using the Entity Beans, I mean BMP?
    3) Have you looked in the features provided by the
    CMP2.0.Let me explain all the patterns I am using. The client is a regular java class that implements the "business delegate" pattern. The business delegate communicates with a session bean that is implementing the "session facade" pattern. It is this session facade that has those methods I referred to above, namely createPerson(), createPhoneNumber() and potentially createPersonTree(). The session facade communicates with a Person entity bean and a PhoneNumber entity bean, which implement the persistence layer. Both of these entity beans use EJB 2.0 CMR and CMP. The actual inserts are performed by these entity beans. For example, inside the session facade's createPerson() method, the session facade delegates the actual insert to the Person entity bean.
    Data is passed between objects by using the "value object" pattern. For example, the business delegate passes person data to the session facade inside a Person value object. The session facade also passes this value object to the entity bean (alternatively, the session facade could pass the person's attributes individually, but I thought this was not as convenient).
    I hope that explains the situation.

  • Shall I use Value Objects???

    Hi,
    I am creating a web app with approx 25 web pages with not much business logic.
    I plan to use struts framework.
    What I wanted to know was, shall I use value object pattern for my web page?
    Is there some kind of questionaire which I can take to decide whether I should use VO or not?
    Thanks,
    KS

    What's the difference between DTO and VO? Both are
    little more than C structs for ferrying data between
    layers. No functionality whatsoever.Value Object was the name used in the first editions of the Applied Java Patterns & Core J2ee Pattern books from Sun. These are called Data Transfer Objects in the later issues of these books.
    The Value Object name also caused some confusion because the term has previously been used to refer to language specific ideoms of wrapping primative types in Object.

  • Design patterns,about value object ,how?why?could you give me a soluttion

    design patterns,about value object ,how?why?could you give me a soluttion
    use value object in ejb,thanks
    i want not set/get the value in ejb,find the method to solve it ,use value
    object ?
    how? thanks.

    Hai
    Enter your telephone number here, at the top it will say your Exchange, Phone and cabient number. If it doesn't mention cabinet that means you are directly connected to the exchange and not via PCP.
    If you are connected to a cabinet and it doesn't say FTTC is available, ask your neighbor to-do the same test (they have 2 be infinity connected). If they are, then proceed to contact the moderators here. Though it could not be showing because all the ports have been used up in the FTTC Cabinet.
    If this helped you please click the Star beside my name.
    If this answered your question please click "Mark as Accepted Solution" below.

  • Value Objects still  relevant in EJB 2.0?

    I came across the concept of using Value Objects to get better performance from EJBs as they reduce the number of remote calls to invoke to retrieve object property values.
    However, with the introduction of LocalHome and Local interfaces for EJB 2.0, is it still useful to have value objects to pass data around, typically between EJBs and the Controller (typically servlets/JSPs or session beans that implement business logic)?

    Not so fast.
    I wouldn't be so quick to get rid of VOs simply because local interfaces exist now. Keep in mind that using local interfaces is not always the right answer to your problem (since there are still situations where the client and server are not co-located within a given VM).
    Also, there are times when the brittleness of your API should be considered. If a method takes many parameters, it is often benificial to pass a single VO as a paramater rather than multiple individual parameters. This really comes into play when methods are modified to take different arguments (e.g. adding a new argument).
    Consider a method on a bean used to update a student's records for example.public StudentVO update(String firstName, String middleInitial, String lastName, int age, String ssn, String status) throws UpdateException; is much more brittle than public StudentVO update(StudentVO student) throws UpdateException;Consider what would happen if a design change makes GPA and gradeLevel part of a student's profile.
    The second method's signature would remain the same. The signature of the first method however would now read public StudentVO update(String firstName, String middleInitial, String lastName, int age, String ssn, String status, float gpa, int gradeLevel) throws UpdateException; This change would "break" the calls made by any callers of this method. While there are pros and cons to this (as well as other ways to solve this issue, such as method overloading, etc.), it is something to consider when deciding whether a value object should be used in certain situations.
    Hope this adds another point of view to the discussion.
    Note: I'm using Value Object (VO), Data Transfer Object (DTO) and Transfer Object (TO) to me the same thing here.

  • Does struts framework only fit Value Object in BC4J?

    1. From "Query Page" to "List Results Page", I use the DataTags to iterate the RowSet.
    Is there any way to save the rowset into the web server to avoid hitting the database again when user wants to turn back from detail page to list page? And then use DataTags again to iterate the saved Rowset.
    2. If database is down, instead of showing the user Http 500 server error, I want to catch it before doing
    <jbo:ApplicationModule ......./> and show user my own message. Is it possible to catch the exception here in JSP?
    3. our application consists of BC4J and Struts. Do we have to create Value Object in BC4J in order to fit Struts framework? Or say, It is only the best way.

    Jane,
    1. From "Query Page" to "List Results Page", I use the DataTags to iterate the RowSet.
    Is there any way to save the rowset into the web server to avoid hitting the database again when user wants to turn back from detail page to list page? And then use DataTags again to iterate the saved Rowset.
    The rowset is saved in the BC4J cache, and it should hit the database only when necessary. The detail set is not eagerly retrieved so only the first time the detail set is browsed, the rows will be fetched with a query.
    Also this depend if you application is stateful or not (using the releasemode property on the ApplicationModule tag). In Stateful mode, the application need to be re-activated and if your AM has been recycled, the data will need to be refetch. In Reserved mode, everything is preserved but you can share you AM with anybody else (faster but less scalable).
    2. If database is down, instead of showing the user Http 500 server error, I want to catch it before doing
    <jbo:ApplicationModule ......./> and show user my own message. Is it possible to catch the exception here in JSP?
    You should be able to try catch around the applicationModule tag. Let me get more info on this one.
    3. our application consists of BC4J and Struts. Do we have to create Value Object in BC4J in order to fit Struts framework? Or say, It is only the best way.
    No, you do no have to create a Value Object in BC4J, but we think it will save you a lot of development time doing so.
    See following links:
    http://otn.oracle.com/products/jdev/htdocs/bc4j9irc_datasheet.html
    http://otn.oracle.com/products/jdev/htdocs/j2ee_bc4j.html
    Charles.

  • 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

  • Dependent Object persistence in EJB 1.1

    Please take a look at the following container-managed entity EJB
    code:
    //REMOTE INTERFACE //----------------------
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    public interface Product extends EJBObject {
    public void setPrice(double price) throws RemoteException;
    public double getPrice() throws RemoteException;
    public String getDescription() throws RemoteException;
    public void setDescription(String desc) throws RemoteException;
    public ItemView getItemView() throws RemoteException;
    public void setItemView(ItemView i) throws RemoteException;
    //HOME INTERFACE //------------------------------
    import java.util.Collection;
    import java.rmi.RemoteException;
    import javax.ejb.*;
    public interface ProductHome extends EJBHome {
    public Product create(String productId, String description,
    double balance, ItemView itemView) throws RemoteException,
    CreateException;
    public Product findByPrimaryKey(String productId)
    throws FinderException, RemoteException;
    public Collection findByDescription(String description)
    throws FinderException, RemoteException;
    public Collection findInRange(double low, double high)
    throws FinderException, RemoteException;
    //EJBean //----------------------------------------------
    import java.util.*;
    import javax.ejb.*;
    public class ProductBean implements EntityBean {
    public String productId;
    public String description;
    public double price;
    //custom java class: Item
    public Item item;
    private EntityContext context;
    public void setPrice(double price) {
    this.price = price;
    public double getPrice() {
    return price;
    //instead of returning field Item, an object of ItemView with Item
    data is returned.
    public ItemView getItemView()
    return new ItemView(item.getDesc(), item.getCodeNum());
    public void setItemView(ItemView itemView)
    this.item = new Item(itemView.getDView(), itemView.getCView
    public String getDescription() { return description; }
    public void setDescription(String descri) {description = descri;}
    public String ejbCreate(String productId, String description,
    double price, ItemView itemView) throws CreateException {
    if (productId == null) {
    throw new CreateException("The productId is required.");
    this.productId = productId;
    this.description = description;
    this.price = price;
    item = new Item(itemView.getDView(), itemView.getCView());
    return null;
    public void setEntityContext(EntityContext context) {
    this.context = context;
    public void ejbActivate() {
    productId = (String)context.getPrimaryKey();
    public void ejbPassivate() {
    productId = null;
    description = null;
    public void ejbRemove() { }
    public void ejbLoad() { }
    public void ejbStore() { }
    public void unsetEntityContext() { }
    public void ejbPostCreate(String productId, String description,
    double balance, ItemView itemView) { System.out.println
    ("ProductBean ejbPostCreate"); }
    } // End of ProductBean
    //Item //-------------
    public class Item implements java.io.Serializable {
    public String desc;
    public int codeNum;
    public Item(String desc, int CodeNum) {
    desc = desc;
    codeNum = codeNum;
    public void setDesc(String decs) {desc = desc;}
    public void setCodeNum(int i) {codeNum = codeNum;}
    public String getDesc() {return desc;}
    public int getCodeNum(){return codeNum;}
    } //End of Item
    //ItemView //-------------------------------------
    public class ItemView implements java.io.Serializable {
    public String dView;
    public int cView;
    public ItemView(String s, int i) {
    dView = s;
    cView = i;
    public void setDView(String s) {dView = s;}
    public String getDView() {return dView; }
    public void setCView(int i) {cView = i;}
    public int getCView() {return cView;}
    Upon running the following client:
    //ProductClient //-------------------------------------
    import java.util.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    public class ProductClient {
    public static void main(String[] args) {
    try {
    Context initial = new InitialContext();
    Object objref = initial.lookup("MyProduct123");
    ProductHome home =
    (ProductHome)PortableRemoteObject.narrow(objref,
    ProductHome.class);
    Product duke = home.create("1006", "Siamese atty", 23.13,
    new ItemView("Hot",12));
    System.out.println("Description: " + duke.getDescription());
    System.out.println("Price: "+ duke.getPrice());
    System.out.println("Item desc: " + duke.getItemView
    ().getDView());
    System.out.println("Item CodeNum: " + duke.getItemView
    ().getCView());
    } catch (Exception ex) {
    System.err.println("Caught an exception." );
    ex.printStackTrace();
    This is expected to create a ProductBean whose Item field variable
    object will have "Hot" and 12 as its values. However, the program
    output is:
    Description: Ceramic Catty
    Price: 19.23
    Item desc: null
    Item CodeNum: 0
    1. I am unable to understand why the Item object contained in the
    ProductBean remains null.
    2. I read in a sdmagazine article, that helper objects (dependent
    objects) should not be exposed directly to the client. I have used
    the ItemView in line with this argument although I am not clear if
    this is a requirement , if so, what is the rationale behind it.
    Please see
    http://www.sdmagazine.com/documents/s=739/sdm0010j/0010j.htm.
    3. If I do not use ItemView and expose the Item field directly to the
    client, there is a runtime error NullPointerExc eption...
    4. Does EJB 2.0 adopts the same approach i.e. can depenmdent objects
    be directly exposed to the client or not. Or this is just a
    recommendation not a requirement?
    In the above mentioned article :
    (http://www.sdmagazine.com/documents/s=739/sdm0010j/0010j.htm)
    "EJB enables me to improve the design I presented in Figure 1. The
    problem is the address attribute; it's an object and not a primitive
    value. Because I need to persist addresses, I have two options: I can
    implement it as a dependent value object or as a dependent object. A
    dependent value object is one that is serializable, the properties of
    which are saved as a single value; it's the relational database
    equivalent of a binary large object (blob). On the other hand, the
    properties of dependent objects are saved as individual values, one
    for each property. This appears to be a significant advantage, but it
    comes at a price: A dependent object must never be directly exposed
    to the clients of entity beans via its remote interface because the
    persistence container is free to optimize the delivery of dependent
    objects and may never fully materialize them as full-fledged classes.
    What you should do, as Figure 2 indicates, is expose a representation
    of the dependent object if required. I have done this with the new
    versions of the getAddress() and setAddress() operations in the
    Customer class that now work with instances of XmlDocument instead of
    Address. A little clunky, but reasonably easy to live with in
    practice. Note that I didn't have to introduce any code to maintain
    the relationship between the two classes to my model."
    5. This is totally new to me. I don't know what the author means when
    he says 'the properties of
    which (dependent object) are saved as individual values, one for each
    property.' Does this mean,
    the dependent object can be persisted in a separate table. How is it
    possible while using CMP? 6.
    And 'all this comes at a price...' I can't see what's the price.
    Any help is highly appreciated.
    Regards,
    Hasan

    Did you forget adding "this." in the item.java.

  • 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

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

  • Why use value objects?

    I am trying to delve a little deeper into Flex and have come across discussions about using value objects. My question is why would you use them?
    I have an application that stores records in a database using ColdFusion as a backend. Currently I use an HTTPService to call a coldfusion page that returns XML that gets put in a XMLListCollection. This is then used to populate a datagrid and form details when the datagrid item is clicked on. This all works fine and is very easy (if not very elegant, it was one of my first applications)
    I have another that uses a remote object to a coldfusion cfc. This cfc returns a query based on verious parameters. This result is then put in an ArrayCollection and used various ways.
    What is wrong with doing things this way and why/how would value objects help?
    Thanks.
    Matt

    Your example has nothing to do with value objects.
    Value objects are useful in a number of situations such as:
    1. They can efficiently represent a limited number of values. Say you have a size field with only four possible values: small, medium, large and extra large. You can use value objects and store the ordinal value (1 to 4) in a single byte instead of needing an 11 byte string. The set of value objects can be used as a white list for validating or constraining user input.
    2. You can attach other information to a value object (within reason). Say your app allows users to select from a list of colors. You can store the RGB color information in the value object for each color.
    There are probably other uses such as with strategy patterns (http://en.wikipedia.org/wiki/Strategy_pattern) as well.

  • Transfer Object pattern question

    Hi, developers!
    I created a Transfer Object pattern class, that has an array field. See below:
    class TOClass {
      private int[] values;
      //notice that I am using clone() method
      public int[] getValues() {
        return (int[])values.clone();
      public void setValues(int[] values) {
        this.values = (int[])values.clone();
    }Would you do like I did?
    Thanks in advance!

    Thank you, you all!
    I am testing the solution you presented, Saish, and I am verifying yet. But I see that the problem of manipulation of data continues, like dubway said. But, this discussion gave me a lot of ideas! (I didn�t know Collections.unmodifiableList() method yet, very interesting method). I will continue my researchs for the best solution.
    But I have to worry only when the getter method is used, because I don�t know what other developers will do with the value returned. I don�t need to worry about setter, because the only person that sets is me, and nobody else.
    And one more thing. My TO class does not contain only one field. There are other fields: Strings, BigDecimals, etc, but these other fields are easy, I just have to create getters and setters for them. There is only one field that has the "behaviour of an array". But because of the fact that there are other fields, to not make this class complicated and "dirty" visually, I really want to use simple getters and setters methods, only. Your solution is not providing getters and setters exactly, Saish. I want to follow the Transfer Object pattern, whose feature is the existence of getters and setters, only.

Maybe you are looking for

  • Can i make a new apple id for my iphone if i forgot the old one

    can i make a new apple id for my iphone if i forgot the old one

  • Install on mac virtual machine  windows

    I have a Parallels Vitural machine on my Imac running Windows 7 - I need Dreamweaver on the Windows platform to work on sits that have coldfusion and need mysql database etc. When I try to install app - it says it will not install on Network drive -

  • Problem with Make (C language) command on Aquamacs

    Hello i'm french.. so sorry for my English i'm trying to do some basics programs on C langage on Aquamacs. but the "make" command does not works with me. my module is like this #include <stdlib.h> #include <stdio.h> #include "arithmetique.h" int max(

  • Audio input problems

    Hi I tried playing in a recording from a Minidisc for editing on Adobe Audition - something I've done many times with Audition on other computers but never with this one. When I opened Audition I got the message:  'Adobe Default Windows Sound Driver.

  • Photoshop and illustrator won't work in my macbook pro

    i tried installing photoshop and illustrator and can't seem to open the applications. i keep getting messages to reinstall the applications. is anyone else having these problems or is it just me? i'm not sure what i'm doing wrong. i was told that ros