Class DBRoomStorageConfig

java.lang.Object
com.smartfoxserver.persistence.room.BaseStorageConfig
com.smartfoxserver.persistence.room.DBRoomStorageConfig

public class DBRoomStorageConfig extends BaseStorageConfig
Provides configuration settings for the Database based Room persistence API
See Also:
  • Field Details

    • dbManager

      public IDBManager dbManager
      An custom DBManager, by default the one configured in the Zone is used
    • tableName

      public String tableName
      Name of the table to use for Room storage
    • testTableExistenceSQL

      public String testTableExistenceSQL
      This SQL is used to test the existence of the table. By default there's no need to change this setting.
    • createTableSQL

      public String createTableSQL
      This is the SQL statement used for creating the table, if it doesn't exist.

      The default value we provide is specific for MySQL, if you are using another database you will need to use a custom statement using the SQL syntax of your DB.

      The database structure is simple:

      Field nameTypeOther
      nameVARCHAR(200)PRIMARY KEY, UNIQUE, NOT NULL
      groupIdVARCHAR(200)KEY, NOT NULL
      roomDataBLOB(200)NOT NULL

      For example this is the default MySQL statement:

       CREATE TABLE %s (
       `name` varchar(200) NOT NULL,
       `groupId` varchar(200) NOT NULL,
       `roomdata` %s NOT NULL,
       PRIMARY KEY (`name`),
       KEY `groupId` (`groupId`)
       ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
       
      NOTE: the %s token after the CREATE TABLE is mandatory and it is replaced at runtime with the configured name of the table

      NOTE: since version 2.9.2 the %s token in the roodata field declaration is mandatory, and it is replaced at runtime with the proper data-type, according to the useTextSerialization setting

    • debugSQL

      public boolean debugSQL
      When set to true it will log the SQL of each performed query
    • useTextSerialization

      public boolean useTextSerialization
      Instead of using a binary serialization the Room data will be converted to JSON and stored as TEXT in the database. This can be helpful if you experience errors with the binary serialization and the blob-type field.

      The default value is false

      PLEASE NOTE: you cannot change this flag after the table in the database has already been created. If you decide to switch from Binary to Text serialization make sure to delete your previous table before restarting the server.

  • Constructor Details

    • DBRoomStorageConfig

      public DBRoomStorageConfig()