package commontypes // JavaTypeMap maps PostgreSQL types to Java types var JavaTypeMap = map[string]string{ // Integer types "integer": "Integer", "int": "Integer", "int4": "Integer", "smallint": "Short", "int2": "Short", "bigint": "Long", "int8": "Long", "serial": "Integer", "bigserial": "Long", "smallserial": "Short", // String types "text": "String", "varchar": "String", "char": "String", "character": "String", "citext": "String", "bpchar": "String", "uuid": "UUID", // Boolean "boolean": "Boolean", "bool": "Boolean", // Float types "real": "Float", "float4": "Float", "double precision": "Double", "float8": "Double", "numeric": "BigDecimal", "decimal": "BigDecimal", // Date/Time types "timestamp": "Timestamp", "timestamp without time zone": "Timestamp", "timestamp with time zone": "Timestamp", "timestamptz": "Timestamp", "date": "Date", "time": "Time", "time without time zone": "Time", "time with time zone": "Time", "timetz": "Time", // Binary "bytea": "byte[]", // JSON "json": "String", "jsonb": "String", } // SQLToJava converts SQL types to Java types func SQLToJava(sqlType string, nullable bool) string { baseType := ExtractBaseType(sqlType) javaType, ok := JavaTypeMap[baseType] if !ok { javaType = "Object" } // Java uses wrapper classes for nullable types by default return javaType }