Meta table

The Meta table in Mint2 is a key value store that can hold information not important enough to end up in their own tables.

Basic access to this table is handled by these static methods:

  • Meta.put( String key, String value ): Stores a value for the specified key. Replaces the value if the key exists.
  • Meta.get( String key ): Gets a value for the specified key or null if the key does not exist.
  • Meta.delete( String key ): Deletes entries with the specified key.

The Meta API has also been extended to support storing properties related to database persistent objects. It uses reflection to generate a key based on the object’s class name, the object’s getDbID method and a property name. The generate key has this form: Class[dbID].property. The following methods are supported:

  • Meta.put( Object object, String property, String value ): Stores a value for the specified object/property pair. Replaces the value if the property exists for this object.
  • Meta.get( Object object, String property ): Gets a value for the specified object/property pair or null if the it does not exist.
  • Meta.delete( Object object, String property ): Deletes property of the specified object.
  • Meta.getAllProperties( Object object ): Gets a list of tuples with all object’s properties and their values.
  • Meta.deleteAllProperties( Object object ): Deletes all properties for the specified object. Useful if the object is going to be removed from the database.

An example of using Meta, is storing user preferences for the mapping editor:

User user = ... /* some user object */
Meta.put(user, "mapping.preferences", "some string value that holds user preferences");

The key generated for this object/property pair is$$_javassist_12[1000].mappings.preferences, where 1000 is the dbID.
The preferences are later retrieved by using:

Meta.get(user, "mapping.preferences");

When the user is deleted, the following should also be called:


Comments are closed.