• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Hashtable Performence

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am required to pass data from presentation layer to Enterprise Java Beans for database related operations. So presently i am passing a hashtable to the EJB that contains data for entire table. Now my problem is when i use hashtable then i have to do lots of get and put operations and every time it does the hashing. Is there any other efficient way to pass the data to ejb. One solution that is coming to my mind is to create a new class that contains all database variables as it's member variable. Now presentation layer can set the value of required member variables of the that class and pass that object to the EJB.
---------------------------------------------
is it more efficient to pass a hashtable or a class object that contains only member variables for the purpose of passing data in terms of memory and time?
------------------

[This message has been edited by yogesh_ar (edited September 12, 2000).]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you mean. A Hashtable is a class object that contains only member variables, isn't it? Perhaps you could provide more details of what you're thinking of.
 
yogesh_ar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jim,
I am required to pass data from presentation layer to Enterprise Java Beans for database related operations. So presently i am passing a hashtable to the EJB that contains data for entire table. Now my problem is when i use hashtable then i have to do lots of get and put operations and every time it does the hashing. Is there any other efficient way to pass the data to ejb? One solution that is coming to my mind is to create a new class that contains all database variables as it's member variable. Now presentation layer can set the value of required member variables of the that class and pass that object to the EJB. Looking for u'r valuable advise..

[This message has been edited by Jim Yingst (edited September 13, 2000).]
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The choice of what kind of data structure to use really depends on how your data is organized, and what you want to do with it. A Hashtable is useful if you want to be able to look up an object using another object as a key - like a dictionary for example. If this is useful to you, then use a Hashtable (or HashMap). If it's not necessary, then use some other structure, like an array, or ArrayList or Vector, or your own custom class(-es) which are organized in a way that makes sense for the data you have. (This last is often the best choice.) But it really depends on how your data is organized, and what you want to do with it. There is no one answer.

[This message has been edited by Jim Yingst (edited September 13, 2000).]
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yogesh,
Using Hashtable is a heavy operation and takes lot of resources(due to re-hashing).
Usually one goes for the hastable when the data to be stored is reasonably more. In normal case you can pass the data from presentation or ui layer and name-value pair Vectors. i.e. one Vector for names and one vector for values.
Hope this make sense and helps.
Give you a call today
Shikhar
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yogesh,
Usage of custom created class encapsulating all the variables from your presentation layer to the EJB is more efficient than using the Hashtable as the latter consumes more resources( I mean here memory).Though you can set the initial size of the Hashtable,it gets incremented when it exceeds the load factor threshold.
Cheers,
Narendra
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"yogesh_ar",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
Sean
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic