Discussions

EJB design: Custom Class Vs HashTable

  1. Custom Class Vs HashTable (3 messages)

    I have a create method in my Entity bean(BMP)the table has 20 columns.

    In order to make the method clean I can think of two options.

    1.) I can create a custom class and make it serializable.
        This class can then be initialized by the client
        and the client can then use it as an argument in
        create method.
    2.) I can create a hash table and pass this as an argument
        in my create method. The client can use the hash table
        and populate the all the values required by the create
        method.

        Which of the above two alternatives is better??

    Thanks

    Threaded Messages (3)

  2. Custom Class Vs HashTable[ Go to top ]

    Hi Pratul,

    I think the paradigm for EJB creation, updating, retrieval, etc... is to use some type of DataBean that maps to your EntityBean. For instance, if you had a EventBean that map to a table called tbl_events that had 20 columns, you would create a corresponding data bean named EventData that had getters/setters for all viewable columns in your tbl_events table. This seems to be a better design as a EventData object represents a something (An event), as a Hashtable is more or less a collection of key/value pairs.

    Hope this helps...
  3. Custom Class Vs HashTable[ Go to top ]

    Look at the 'Details Object' pattern posted on this site in the Patterns section by Floyd.
  4. Custom Class Vs HashTable[ Go to top ]

    hi, u can use hashtable instead of ur own class bcuz if u have ur own class then it has to be present in the client side (java client appln) as well as the serverside.
    If u have lot more things like this ur client will become bulky..so better use Hashtable to avoid this situation.
    -RK