Caching system for loading reference table data
Hi,
I want to load the small reference table data into memory and later i want to query the data in the memory. That table wont be updated frequenctly.I dont want to to load the query results in the memory. As i know i can do it by IBatis or Hibernate. I want to load the reference table data into memory once and want to use the data in memory for querying. Suppose i have a Department table with 100 rows with columns as DeptNO, DeptName and NoOfEmployees. I want to load all the records in to memory and later i want to run queries like getDepartmes where NoEmployees >50. queries can be dynamic.Is it possible with any Java caching systems.
[660 byte] By [
kumvala] at [2007-11-26 17:49:59]

Actually, HSQLDB makes a pretty nice caching system. It is an in-memory database, so if you created an in-memory database and copied data to it when the program started up, it would provide an SQL-accessible cache source. That's probably the first avenue I'd pursue.
They allow you to manipulate collections (duh) of objects. Typically, but not exclusively, using a comparator or somesuch. The sort of operation you're describing can be carried out reasonably swiftly by merely iterating over the items - unlikely to be as slow as a database round-trip.
If you need something particularly sophisticated then you can either craft a suitable data structure to contain it, or go for the generic solution of an embedded database (and if you go for this option, you might want to apologise for biting my head off).
Or, indeed, you can use a query cache if you need no dynamic capabilities whatsoever (i.e. query with a <50 constraint twice and the second one is fast, but do it again with a <49 constraint and it takes just as long as the first one).