Class DBRoomStorageConfig
- java.lang.Object
-
- com.smartfoxserver.v2.persistence.room.BaseStorageConfig
-
- com.smartfoxserver.v2.persistence.room.DBRoomStorageConfig
-
public class DBRoomStorageConfig extends BaseStorageConfig
Provides configuration settings for the Database based Room persistence API- Since:
- 2.8.0
- See Also:
BaseStorageConfig
,IRoomStorage
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String
createTableSQL
This is the SQL statement used for creating the table, if it doesn't exist.IDBManager
dbManager
An custom DBManager, by default the one configured in the Zone is usedboolean
debugSQL
When set to true it will log the SQL of each performed queryjava.lang.String
tableName
Name of the table to use for Room storagejava.lang.String
testTableExistenceSQL
This SQL is used to test the existence of the table.boolean
useTextSerialization
Instead of using a binary serialization the Room data will be converted to JSON and stored as TEXT in the database.-
Fields inherited from class com.smartfoxserver.v2.persistence.room.BaseStorageConfig
customStorageClassName, skipStaticRooms, storeInactiveRooms, storeRoomVariables
-
-
Constructor Summary
Constructors Constructor Description DBRoomStorageConfig()
-
-
-
Field Detail
-
dbManager
public IDBManager dbManager
An custom DBManager, by default the one configured in the Zone is used
-
tableName
public java.lang.String tableName
Name of the table to use for Room storage
-
testTableExistenceSQL
public java.lang.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 java.lang.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 name Type Other name VARCHAR(200) PRIMARY KEY, UNIQUE, NOT NULL groupId VARCHAR(200) KEY, NOT NULL roomData BLOB(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 tableNOTE: 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.
- Since:
- 2.9.2
-
-