Package org.zalando.typemapper.postgres
Class PgTypeHelper
- java.lang.Object
-
- org.zalando.typemapper.postgres.PgTypeHelper
-
public class PgTypeHelper extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPgTypeHelper.PgTypeDataHolder
-
Constructor Summary
Constructors Constructor Description PgTypeHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PgRowasPGobject(Object o)static PgRowasPGobject(Object o, String typeHint)static PgRowasPGobject(Object o, String typeHint, Connection connection)static PgRowasPGobject(Object o, String typeHint, Connection connection, boolean forceTypeHint)static DatabaseFieldDescriptorgetDatabaseFieldDescriptor(Field field)get the database field annotation from a given field.static PgTypeHelper.PgTypeDataHoldergetObjectAttributesForPgSerialization(Object obj, String typeHint)static PgTypeHelper.PgTypeDataHoldergetObjectAttributesForPgSerialization(Object obj, String typeHint, Connection connection)static PgTypeHelper.PgTypeDataHoldergetObjectAttributesForPgSerialization(Object obj, String typeHint, Connection connection, boolean forceTypeHint)static StringgetSQLNameForClass(Class<?> elementClass)static intgetSQLType(String typeName)A simple method to get an appropriate java.sql.types.* value for the given PostgreSQL type namestatic StringtoPgString(Object o)static StringtoPgString(Object o, Connection connection)Serialize an object into a PostgreSQL string.
-
-
-
Method Detail
-
getSQLType
public static final int getSQLType(String typeName)
A simple method to get an appropriate java.sql.types.* value for the given PostgreSQL type name- Parameters:
typeName-- Returns:
- SQL type
-
getObjectAttributesForPgSerialization
public static PgTypeHelper.PgTypeDataHolder getObjectAttributesForPgSerialization(Object obj, String typeHint)
-
getObjectAttributesForPgSerialization
public static PgTypeHelper.PgTypeDataHolder getObjectAttributesForPgSerialization(Object obj, String typeHint, Connection connection)
-
getObjectAttributesForPgSerialization
public static PgTypeHelper.PgTypeDataHolder getObjectAttributesForPgSerialization(Object obj, String typeHint, Connection connection, boolean forceTypeHint)
-
getDatabaseFieldDescriptor
public static DatabaseFieldDescriptor getDatabaseFieldDescriptor(Field field)
get the database field annotation from a given field. This function will check againstColumndefinition so that both annotations can be used to mark a DatabaseField.- Parameters:
field- the field to be checked- Returns:
- a
DatabaseFieldDescriptorbased on a foundDatabaseFieldorColumn
-
toPgString
public static String toPgString(Object o, Connection connection)
Serialize an object into a PostgreSQL string.- Parameters:
o- object to be serialized
-
asPGobject
public static PgRow asPGobject(Object o) throws SQLException
- Throws:
SQLException
-
asPGobject
public static PgRow asPGobject(Object o, String typeHint) throws SQLException
- Throws:
SQLException
-
asPGobject
public static PgRow asPGobject(Object o, String typeHint, Connection connection) throws SQLException
- Throws:
SQLException
-
asPGobject
public static PgRow asPGobject(Object o, String typeHint, Connection connection, boolean forceTypeHint) throws SQLException
- Throws:
SQLException
-
-