Class SqlStructGenerator
- All Implemented Interfaces:
DataGenerator<Struct>
STRUCT (structured / user-defined type) columns.
generate() intentionally returns null. A Struct
cannot be synthesized in memory: the only portable way to create one is
Connection.createStruct(typeName, attributes), which requires a live Connection, the SQL type name, and one correctly typed value per attribute. The
generate() contract exposes none of these, and the JDBC drivers this library targets
(PostgreSQL, MySQL, CockroachDB) do not implement createStruct — it throws
SQLFeatureNotSupportedException. Returning null lets nullable
STRUCT columns fill; a non-nullable one will fail at insert.
get(ResultSet, int) reads an existing Struct normally, so round-tripping a
value already present in a ResultSet works.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class AbstractDataGenerator
random, randomUtils -
Method Summary
Methods inherited from class AbstractDataGenerator
generateAndSet, reseed, set
-
Method Details
-
generate
Generates a random value of type T.Always returns
null; see the class documentation for why aStructcannot be generated.- Returns:
- a generated value, may be null if the generator supports nullable columns
-
generateAsString
Description copied from interface:DataGeneratorGenerates a value and returns its string representation.- Specified by:
generateAsStringin interfaceDataGenerator<Struct>- Overrides:
generateAsStringin classAbstractDataGenerator<Struct>- Returns:
- the string representation of a generated value
-
get
Description copied from interface:DataGeneratorRetrieves a value from a ResultSet column.- Parameters:
resultSet- the result set to read fromcolumnIndex- the 1-based column index- Returns:
- the value from the result set, properly cast to type T
- Throws:
SQLException- if the database operation fails
-