Ref
Stay organized with collections
Save and categorize content based on your preferences.
The mapping in the Java programming language of an SQL REF
value, which is a reference to an SQL structured type value in the database.
SQL REF
values are stored in a table that contains
instances of a referenceable SQL structured type, and each REF
value is a unique identifier for one instance in that table.
An SQL REF
value may be used in place of the
SQL structured type it references, either as a column value in a
table or an attribute value in a structured type.
Because an SQL REF
value is a logical pointer to an
SQL structured type, a Ref
object is by default also a logical
pointer. Thus, retrieving an SQL REF
value as
a Ref
object does not materialize
the attributes of the structured type on the client.
A Ref
object can be stored in the database using the
PreparedStatement.setRef
method.
All methods on the Ref
interface must be fully implemented if the
JDBC driver supports the data type.
Public Method Summary
abstract
String
|
getBaseTypeName()
Retrieves the fully-qualified SQL name of the SQL structured type that
this Ref object references.
|
abstract
Object
|
getObject()
Retrieves the SQL structured type instance referenced by
this Ref object.
|
abstract
Object
|
getObject( Map< String, Class<?>> map)
Retrieves the referenced object and maps it to a Java type
using the given type map.
|
abstract
void
|
setObject( Object value)
Sets the structured type value that this Ref
object references to the given instance of Object .
|
Public Methods
public
abstract
String
getBaseTypeName
()
Retrieves the fully-qualified SQL name of the SQL structured type that
this Ref
object references.
Returns
- the fully-qualified SQL name of the referenced SQL structured type
public
abstract
Object
getObject
()
Retrieves the SQL structured type instance referenced by
this Ref
object. If the connection's type map has an entry
for the structured type, the instance will be custom mapped to
the Java class indicated in the type map. Otherwise, the
structured type instance will be mapped to a Struct
object.
Returns
- a Java
Object
that is the mapping for
the SQL structured type to which this Ref
object refers
Retrieves the referenced object and maps it to a Java type
using the given type map.
Parameters
map |
a java.util.Map object that contains
the mapping to use (the fully-qualified name of the SQL
structured type being referenced and the class object for
SQLData implementation to which the SQL
structured type will be mapped) |
Returns
- a Java
Object
that is the custom mapping for
the SQL structured type to which this Ref
object refers
public
abstract
void
setObject
(Object value)
Sets the structured type value that this Ref
object references to the given instance of Object
.
The driver converts this to an SQL structured type when it
sends it to the database.
Parameters
value |
an Object representing the SQL
structured type instance that this
Ref object will reference |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["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 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eRef\u003c/code\u003e represents a reference to an SQL structured type value within a database, acting as a unique identifier for a specific instance in a table.\u003c/p\u003e\n"],["\u003cp\u003eBy default, a \u003ccode\u003eRef\u003c/code\u003e object acts as a logical pointer and retrieving it does not automatically materialize the attributes of the referenced structured type on the client-side.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRef\u003c/code\u003e interface provides methods to retrieve the fully-qualified name of the referenced SQL structured type, obtain the referenced structured type instance, and set the referenced structured type value.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eRef\u003c/code\u003e objects can be persistently stored in the database utilizing the \u003ccode\u003ePreparedStatement.setRef\u003c/code\u003e method.\u003c/p\u003e\n"]]],[],null,["# Ref\n\npublic interface **Ref** \nThe mapping in the Java programming language of an SQL `REF`\nvalue, which is a reference to an SQL structured type value in the database.\n\n\nSQL `REF` values are stored in a table that contains\ninstances of a referenceable SQL structured type, and each `REF`\nvalue is a unique identifier for one instance in that table.\nAn SQL `REF` value may be used in place of the\nSQL structured type it references, either as a column value in a\ntable or an attribute value in a structured type.\n\n\nBecause an SQL `REF` value is a logical pointer to an\nSQL structured type, a `Ref` object is by default also a logical\npointer. Thus, retrieving an SQL `REF` value as\na `Ref` object does not materialize\nthe attributes of the structured type on the client.\n\n\nA `Ref` object can be stored in the database using the\n`PreparedStatement.setRef` method.\n\n\nAll methods on the `Ref` interface must be fully implemented if the\nJDBC driver supports the data type. \n\n##### See Also\n\n- [Struct](../../../reference/java/sql/Struct.html) \n\n### Public Method Summary\n\n|-------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [String](../../../reference/java/lang/String.html) | [getBaseTypeName](../../../reference/java/sql/Ref.html#getBaseTypeName())() Retrieves the fully-qualified SQL name of the SQL structured type that this `Ref` object references. |\n| abstract [Object](../../../reference/java/lang/Object.html) | [getObject](../../../reference/java/sql/Ref.html#getObject())() Retrieves the SQL structured type instance referenced by this `Ref` object. |\n| abstract [Object](../../../reference/java/lang/Object.html) | [getObject](../../../reference/java/sql/Ref.html#getObject(java.util.Map\u003cjava.lang.String,%20java.lang.Class\u003c?\u003e\u003e))([Map](../../../reference/java/util/Map.html)\\\u003c[String](../../../reference/java/lang/String.html), [Class](../../../reference/java/lang/Class.html)\\\u003c?\\\u003e\\\u003e map) Retrieves the referenced object and maps it to a Java type using the given type map. |\n| abstract void | [setObject](../../../reference/java/sql/Ref.html#setObject(java.lang.Object))([Object](../../../reference/java/lang/Object.html) value) Sets the structured type value that this `Ref` object references to the given instance of `Object`. |\n\nPublic Methods\n--------------\n\n#### public abstract [String](../../../reference/java/lang/String.html)\n**getBaseTypeName**\n()\n\nRetrieves the fully-qualified SQL name of the SQL structured type that\nthis `Ref` object references. \n\n##### Returns\n\n- the fully-qualified SQL name of the referenced SQL structured type \n\n##### Throws\n\n| [SQLException](../../../reference/java/sql/SQLException.html) | if a database access error occurs |\n| [SQLFeatureNotSupportedException](../../../reference/java/sql/SQLFeatureNotSupportedException.html) | if the JDBC driver does not support this method |\n|-----------------------------------------------------------------------------------------------------|-------------------------------------------------|\n\n#### public abstract [Object](../../../reference/java/lang/Object.html)\n**getObject**\n()\n\nRetrieves the SQL structured type instance referenced by\nthis `Ref` object. If the connection's type map has an entry\nfor the structured type, the instance will be custom mapped to\nthe Java class indicated in the type map. Otherwise, the\nstructured type instance will be mapped to a `Struct` object. \n\n##### Returns\n\n- a Java `Object` that is the mapping for the SQL structured type to which this `Ref` object refers \n\n##### Throws\n\n| [SQLException](../../../reference/java/sql/SQLException.html) | if a database access error occurs |\n| [SQLFeatureNotSupportedException](../../../reference/java/sql/SQLFeatureNotSupportedException.html) | if the JDBC driver does not support this method |\n|-----------------------------------------------------------------------------------------------------|-------------------------------------------------|\n\n##### See Also\n\n- [setObject(Object)](../../../reference/java/sql/Ref.html#setObject(java.lang.Object)) \n\n#### public abstract [Object](../../../reference/java/lang/Object.html)\n**getObject**\n([Map](../../../reference/java/util/Map.html)\\\u003c[String](../../../reference/java/lang/String.html), [Class](../../../reference/java/lang/Class.html)\\\u003c?\\\u003e\\\u003e map)\n\nRetrieves the referenced object and maps it to a Java type\nusing the given type map. \n\n##### Parameters\n\n| map | a `java.util.Map` object that contains the mapping to use (the fully-qualified name of the SQL structured type being referenced and the class object for `SQLData` implementation to which the SQL structured type will be mapped) |\n|-----|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- a Java `Object` that is the custom mapping for the SQL structured type to which this `Ref` object refers \n\n##### Throws\n\n| [SQLException](../../../reference/java/sql/SQLException.html) | if a database access error occurs |\n| [SQLFeatureNotSupportedException](../../../reference/java/sql/SQLFeatureNotSupportedException.html) | if the JDBC driver does not support this method |\n|-----------------------------------------------------------------------------------------------------|-------------------------------------------------|\n\n##### See Also\n\n- [setObject(Object)](../../../reference/java/sql/Ref.html#setObject(java.lang.Object)) \n\n#### public abstract void\n**setObject**\n([Object](../../../reference/java/lang/Object.html) value)\n\nSets the structured type value that this `Ref`\nobject references to the given instance of `Object`.\nThe driver converts this to an SQL structured type when it\nsends it to the database. \n\n##### Parameters\n\n| value | an `Object` representing the SQL structured type instance that this `Ref` object will reference |\n|-------|-------------------------------------------------------------------------------------------------|\n\n##### Throws\n\n| [SQLException](../../../reference/java/sql/SQLException.html) | if a database access error occurs |\n| [SQLFeatureNotSupportedException](../../../reference/java/sql/SQLFeatureNotSupportedException.html) | if the JDBC driver does not support this method |\n|-----------------------------------------------------------------------------------------------------|-------------------------------------------------|\n\n##### See Also\n\n- [getObject()](../../../reference/java/sql/Ref.html#getObject())\n- [getObject(Map)](../../../reference/java/sql/Ref.html#getObject(java.util.Map\u003cjava.lang.String,%20java.lang.Class\u003c?\u003e\u003e))\n- [PreparedStatement.setObject(int, Object)](../../../reference/java/sql/PreparedStatement.html#setObject(int,%20java.lang.Object))\n- [CallableStatement.setObject(String, Object)](../../../reference/java/sql/CallableStatement.html#setObject(java.lang.String,%20java.lang.Object))"]]