Commits the current transaction and persists any changes to the settings (except local
changes).
generatePGSettingsCte()
publicStringgeneratePGSettingsCte()
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 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.
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.
Returns whether DROP ... CASCADE statements are supported. This also includes implicit
cascading operations, such as dropping indexes of tables that are being dropped.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Class SessionState (0.27.1)\n\nVersion latestkeyboard_arrow_down\n\n- [0.27.1 (latest)](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.27.0](/java/docs/reference/pgadapter/0.27.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.26.0](/java/docs/reference/pgadapter/0.26.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.25.0](/java/docs/reference/pgadapter/0.25.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.24.0](/java/docs/reference/pgadapter/0.24.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.23.1](/java/docs/reference/pgadapter/0.23.1/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.22.1](/java/docs/reference/pgadapter/0.22.1/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.21.0](/java/docs/reference/pgadapter/0.21.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.20.0](/java/docs/reference/pgadapter/0.20.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.19.1](/java/docs/reference/pgadapter/0.19.1/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.18.4](/java/docs/reference/pgadapter/0.18.4/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.17.0](/java/docs/reference/pgadapter/0.17.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.16.0](/java/docs/reference/pgadapter/0.16.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.15.0](/java/docs/reference/pgadapter/0.15.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.14.1](/java/docs/reference/pgadapter/0.14.1/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.9.0](/java/docs/reference/pgadapter/0.9.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.8.0](/java/docs/reference/pgadapter/0.8.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.7.0](/java/docs/reference/pgadapter/0.7.0/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.6.1](/java/docs/reference/pgadapter/0.6.1/com.google.cloud.spanner.pgadapter.session.SessionState)\n- [0.5.1](/java/docs/reference/pgadapter/0.5.1/com.google.cloud.spanner.pgadapter.session.SessionState) \n\n public class SessionState\n\n[SessionState](/java/docs/reference/pgadapter/latest/com.google.cloud.spanner.pgadapter.session.SessionState) contains all session variables for a connection. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e SessionState \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nConstructors\n------------\n\n### SessionState(OptionsMetadata options)\n\n public SessionState(OptionsMetadata options)\n\nMethods\n-------\n\n### commit()\n\n public void commit()\n\nCommits the current transaction and persists any changes to the settings (except local\nchanges).\n\n### generatePGSettingsCte()\n\n public String generatePGSettingsCte()\n\nGenerates a Common Table Expression that represents the pg_settings table. Note that the\ngenerated query adds two additional CTEs that could in theory hide existing user tables. It is\nhowever strongly recommended that user tables never start with 'pg_', as all system tables in\nPostgreSQL start with 'pg_' and 'pg_catalog' is by design always included in the search_path\nand is by default the first entry on the search_path. This means that user tables that start\nwith 'pg_' always risk being hidden by user tables, unless pg_catalog has been explicitly added\nto the search_path after one or more user schemas.\n\n### get(String extension, String name)\n\n public PGSetting get(String extension, String name)\n\nReturns the current value of the specified setting.\n\n### getAll()\n\n public List\u003cPGSetting\u003e getAll()\n\nReturns all settings and their current values.\n\n### getDdlTransactionMode()\n\n public OptionsMetadata.DdlTransactionMode getDdlTransactionMode()\n\nReturns the DdlTransactionMode that is used for this connection at this time.\n\n### getLogSlowStatementThreshold()\n\n public Duration getLogSlowStatementThreshold()\n\nReturns the threshold for when a query should be considered slow and should be logged.\n\n### getServerVersion()\n\n public String getServerVersion()\n\nReturns the PostgreSQL version.\n\n### getTimezone()\n\n public ZoneId getTimezone()\n\nReturns the [ZoneId](https://docs.oracle.com/javase/8/docs/api/java/time/ZoneId.html) of the current timezone for this session.\n\n### isAutoAddLimitClause()\n\n public boolean isAutoAddLimitClause()\n\nReturns whether statements with an OFFSET clause that uses a parameter should be automatically\nappended with a LIMIT clause. The LIMIT clause will use the literal Long.MAX_VALUE for unbound\nstatements, and Long.MAX_VALUE - offset for bound statements.\n\nThis method will be removed in the future.\n\n### isEmulatePgClassTables()\n\n public boolean isEmulatePgClassTables()\n\nReturns the current setting for replacing pg_class tables with common table expressions that\nuse the object name as OID.\n\n### isForceAutocommit()\n\n public boolean isForceAutocommit()\n\nReturns whether transaction statements should be ignored and all statements should be executed\nin autocommit mode.\n\n### isReplaceForUpdateClause()\n\n public boolean isReplaceForUpdateClause()\n\nReturns whether `FOR UPDATE` clauses will automatically be replaced with a\nLOCK_SCANNED_RANGES=exclusive hint. These statements are sometimes generated by ORMs, like for\nexample Hibernate.\n\nThis method will be removed in the future.\n\n### isReplacePgCatalogTables()\n\n public boolean isReplacePgCatalogTables()\n\nReturns the current setting for replacing pg_catalog tables with common table expressions.\n\n### isSupportDropCascade()\n\n public boolean isSupportDropCascade()\n\nReturns whether DROP ... CASCADE statements are supported. This also includes implicit\ncascading operations, such as dropping indexes of tables that are being dropped.\n\n### resetAll()\n\n public void resetAll()\n\nResets all values to their 'reset' value.\n\n### rollback()\n\n public void rollback()\n\nRolls back the current transaction and abandons any pending changes to the settings.\n\n### set(String extension, String name, String setting)\n\n public void set(String extension, String name, String setting)\n\nSets the value of the specified setting. The new value will be persisted if the current\ntransaction is committed. The value will be lost if the transaction is rolled back.\n\n### setConnectionStartupValue(String extension, String name, String value)\n\n public void setConnectionStartupValue(String extension, String name, String value)\n\nSets the value of the specified setting at connection startup.\n\n### setLocal(String extension, String name, String setting)\n\n public void setLocal(String extension, String name, String setting)\n\nSets the value of the specified setting for the current transaction. This value is lost when\nthe transaction is committed or rolled back.\n\n### tryGet(String extension, String name)\n\n public PGSetting tryGet(String extension, String name)\n\nReturns the current value of the specified setting or null if undefined."]]