Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

most efficient reference lookup for business objects?

Thread view: 
Timasmith - 06 Nov 2006 01:59 GMT
Hi,

I have database tables which translate into business objects with 20-30
fields, 5-10 child objects with again 20-30 fields.

50% of the fields are a long integer relatiing to a reference table.
In the object I have a display field which equates to the reference
table display.

Every time I pull an object out of the database I populate its
reference displays, making it very easy to present searches, populate
combo lists etc.

However there is a cost to populating the object with all the 150+
display values.  If I am pulling out 50-100 objects from search
results, that is a lot of lookups.

Since I'm stubborn I refuse to entertain passing this workload on to
the database.  I dont care how efficient their caching is - that is not
going to scale very well and it would be too complex to figure out
clustering on the database side as I am supporting at least one open
source database.

As an FYI this is running on JBoss under a stateless session bean, I do
use Hibernate for the data layer.

So what I did was I have a local stateless session bean which performs
the 'reference lookup'.  Every time it does it, it pops the display and
the id into a hashtable for next time.  In fact in some cases it pops
an entire business object into the hash.

I wondered if the old Hashtable was really the right thing for this.
It works, though obviously there is a danger that the cache would need
purging to remain efficient and not hog too much memory.  While I have
a first pass at synchronizing the code, it probably needs more work to
be more efficient.

I also do this on the client - where it really helps as the client does
not ask for business objects in the first place if they are cached
locally.  Of course when the client restarts that is lost.

I considered caching the reference locally on the client.  Obviously a
lot of extra work to prevent stale data.

Any other ideas on how to improve this?

thanks
Daniel Pitts - 06 Nov 2006 02:48 GMT
> Hi,
>
[quoted text clipped - 43 lines]
>
> thanks

There are built in caching mechanisms for Hibernate, I wouldn't try to
invent your own.
If you don't need all of the data all of the time, you might try using
lazy-loading.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.