Class SessionState (0.22.0)

public class SessionState

SessionState contains all session variables for a connection.

Inheritance

java.lang.Object > SessionState

Constructors

SessionState(OptionsMetadata options)

public SessionState(OptionsMetadata options)
Parameter
NameDescription
optionsOptionsMetadata

Methods

commit()

public void commit()

Commits the current transaction and persists any changes to the settings (except local changes).

generatePGSettingsCte()

public String generatePGSettingsCte()

Generates a Common Table Expression that represents the pg_settings table. Note that the generated query adds two additional CTEs that could in theory hide existing user tables. It is however strongly recommended that user tables never start with 'pg_', as all system tables in PostgreSQL start with 'pg_' and 'pg_catalog' is by design always included in the search_path and is by default the first entry on the search_path. This means that user tables that start with 'pg_' always risk being hidden by user tables, unless pg_catalog has been explicitly added to the search_path after one or more user schemas.

Returns
TypeDescription
String

get(String extension, String name)

public PGSetting get(String extension, String name)

Returns the current value of the specified setting.

Parameters
NameDescription
extensionString
nameString
Returns
TypeDescription
PGSetting

getAll()

public List<PGSetting> getAll()

Returns all settings and their current values.

Returns
TypeDescription
List<PGSetting>

getDdlTransactionMode()

public OptionsMetadata.DdlTransactionMode getDdlTransactionMode()

Returns the DdlTransactionMode that is used for this connection at this time.

Returns
TypeDescription
OptionsMetadata.DdlTransactionMode

getServerVersion()

public String getServerVersion()

Returns the PostgreSQL version.

Returns
TypeDescription
String

getTimezone()

public ZoneId getTimezone()

Returns the ZoneId of the current timezone for this session.

Returns
TypeDescription
ZoneId

isAutoAddLimitClause()

public boolean isAutoAddLimitClause()

Returns whether statements with an OFFSET clause that uses a parameter should be automatically appended with a LIMIT clause. The LIMIT clause will use the literal Long.MAX_VALUE for unbound statements, and Long.MAX_VALUE - offset for bound statements.

This method will be removed in the future.

Returns
TypeDescription
boolean

isEmulatePgClassTables()

public boolean isEmulatePgClassTables()

Returns the current setting for replacing pg_class tables with common table expressions that use the object name as OID.

Returns
TypeDescription
boolean

isForceAutocommit()

public boolean isForceAutocommit()

Returns whether transaction statements should be ignored and all statements should be executed in autocommit mode.

Returns
TypeDescription
boolean

isReplaceForUpdateClause()

public boolean isReplaceForUpdateClause()

Returns whether FOR UPDATE clauses will automatically be replaced with a LOCK_SCANNED_RANGES=exclusive hint. These statements are sometimes generated by ORMs, like for example Hibernate.

This method will be removed in the future.

Returns
TypeDescription
boolean

isReplacePgCatalogTables()

public boolean isReplacePgCatalogTables()

Returns the current setting for replacing pg_catalog tables with common table expressions.

Returns
TypeDescription
boolean

resetAll()

public void resetAll()

Resets all values to their 'reset' value.

rollback()

public void rollback()

Rolls back the current transaction and abandons any pending changes to the settings.

set(String extension, String name, String setting)

public void set(String extension, String name, String setting)

Sets the value of the specified setting. The new value will be persisted if the current transaction is committed. The value will be lost if the transaction is rolled back.

Parameters
NameDescription
extensionString
nameString
settingString

setConnectionStartupValue(String extension, String name, String value)

public void setConnectionStartupValue(String extension, String name, String value)

Sets the value of the specified setting at connection startup.

Parameters
NameDescription
extensionString
nameString
valueString

setLocal(String extension, String name, String setting)

public void setLocal(String extension, String name, String setting)

Sets the value of the specified setting for the current transaction. This value is lost when the transaction is committed or rolled back.

Parameters
NameDescription
extensionString
nameString
settingString

tryGet(String extension, String name)

public PGSetting tryGet(String extension, String name)

Returns the current value of the specified setting or null if undefined.

Parameters
NameDescription
extensionString
nameString
Returns
TypeDescription
PGSetting