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]
# 1
If your queries are dynamic and you want to conduct them using SQL your best bet would be to SELECT the appropriate rows from the underlying database, then INSERT them into an embedded database such as Derby or HSQLDB.
dcmintera at 2007-7-9 5:02:29 > top of Java-index,Java Essentials,Java Programming...
# 2

I asked for caching system. You are recommending a seperate database. The only reason for cache the reference data is to improve the performance instead of invoking the database layer for reference data. Whats the use in using another database. It introduces extra complexity. I didn't mean i want to only SQl on cached reference data. I can also use object query language on cached data object. I want to know any caching system support it.

kumvala at 2007-7-9 5:02:29 > top of Java-index,Java Essentials,Java Programming...
# 3
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.
kevjavaa at 2007-7-9 5:02:29 > top of Java-index,Java Essentials,Java Programming...
# 4
And what exactly do you imagine to be the difference between your magic caching system that understands SQL and an embedded database?And if you don't want SQL, then what for god's sake is wrong with the ruddy Collection classes?
dcmintera at 2007-7-9 5:02:29 > top of Java-index,Java Essentials,Java Programming...
# 5
Hi,Could you elobarate the difference? What is the speciality of ruddy Collections?
kumvala at 2007-7-9 5:02:29 > top of Java-index,Java Essentials,Java Programming...
# 6

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).

dcmintera at 2007-7-9 5:02:29 > top of Java-index,Java Essentials,Java Programming...