Database Lookup

    Options

    Note on the Load all data from table option: As an example: when storing a value of type “CHAR(3)”, many databases will store “ab” using 3 characters: “ab “ (notice the blank space). When you do a “SELECT * FROM my_lookup_table WHERE key_column = ‘ab’”, the database is smart and adds a blank space before applying the where clause (it looks for ‘ab ‘ instead of ‘ab’).

    The problem occurs when you use “load all data from table” to pre-load the cache: at startup, the cache is built using all the values present in the database, so we store ‘ab ‘ in the cache. Later, looking up ‘ab’ fails, because the trailing space matters in java equality.