private DbPlatformType getJsonType(DbType type, boolean withScale) { DbPlatformType dbType = get(type); if (dbType == JSON_CLOB_PLACEHOLDER) { // if we have scale that implies this maps to varchar return withScale ? get(DbType.VARCHAR) : get(DbType.CLOB); } if (dbType == JSON_BLOB_PLACEHOLDER) { return get(DbType.BLOB); } if (dbType == JSON_VARCHAR_PLACEHOLDER) { return get(DbType.VARCHAR); } // Postgres has specific type return get(type); }
/** * Lookup the platform specific DbType given the standard sql type name. */ public DbPlatformType lookup(String name, boolean withScale) { DbType type = lookup.byName(name); if (type == null) { throw new IllegalArgumentException("Unknown type [" + name + "] - not standard sql type"); } // handle JSON types mapped to clob, blob and varchar switch (type) { case JSONBLOB: return get(DbType.BLOB); case JSONCLOB: return get(DbType.CLOB); case JSONVARCHAR: return get(DbType.VARCHAR); case JSON: return getJsonType(DbType.JSON, withScale); case JSONB: return getJsonType(DbType.JSONB, withScale); default: return get(type); } }
/** * Return the type for a given jdbc type. */ public DbPlatformType get(int jdbcType) { return get(lookup.byId(jdbcType)); }
private DbPlatformType getDbType(BeanProperty p) { if (p.isDbEncrypted()) { return dbTypeMap.get(p.getDbEncryptedType()); } if (p.isLocalEncrypted()) { // scalar type potentially wrapping varbinary db type ScalarType<Object> scalarType = p.getScalarType(); int jdbcType = scalarType.getJdbcType(); return dbTypeMap.get(jdbcType); } // can be the logical JSON types (JSON, JSONB, JSONClob, JSONBlob, JSONVarchar) int dbType = p.getDbType(platformTypes); if (dbType == 0) { throw new RuntimeException("No scalarType defined for " + p.getFullBeanName()); } return dbTypeMap.get(dbType); }
/** * Map the UUID appropriately based on native DB support and ServerConfig.DbUuid. */ public void config(boolean nativeUuidType, ServerConfig.DbUuid dbUuid) { if (nativeUuidType && dbUuid.useNativeType()) { put(DbType.UUID, UUID_NATIVE); } else if (dbUuid.useBinary()) { put(DbType.UUID, get(DbType.BINARY).withLength(16)); } else { put(DbType.UUID, get(DbType.VARCHAR).withLength(40)); } } }
DbPlatformType dbType = ctx.getDbTypeMap().get(inheritInfo.getDiscriminatorType()); String discDbType = dbType.renderType(inheritInfo.getDiscriminatorLength(), 0);
put(DbType.JSONVARCHAR, JSON_VARCHAR_PLACEHOLDER); put(DbType.UUID, get(DbType.VARCHAR).withLength(40));