/** * Return the DB column type definition. */ public String renderDbType(DbPlatformType dbType, boolean strict) { if (dbColumnDefn != null) { return dbColumnDefn; } return dbType.renderType(dbLength, dbScale, strict); }
/** * Return the type for a specific property that incorporates the name, length, * precision and scale. * <p> * The deployLength and deployScale are for the property we are rendering the * DB type for. * </p> * * @param deployLength the length or precision defined by deployment on a specific * property. * @param deployScale the scale defined by deployment on a specific property. */ public String renderType(int deployLength, int deployScale) { return renderType(deployLength, deployScale, true); }
/** * Convert a simple type with not scale or precision. */ protected String convertNoScale(String columnDefinition) { try { DbPlatformType dbType = platformTypes.lookup(columnDefinition, false); return dbType.renderType(0, 0); } catch (IllegalArgumentException e) { // assume already platform specific, leave as is return columnDefinition; } }
/** * Convert a type that has scale and possibly precision. */ protected String convertWithScale(String columnDefinition, int open) { int close = columnDefinition.lastIndexOf(')'); if (close == -1) { // assume already platform specific, leave as is return columnDefinition; } String suffix = close + 1 < columnDefinition.length() ? columnDefinition.substring(close + 1) : ""; String type = columnDefinition.substring(0, open); try { DbPlatformType dbType = platformTypes.lookup(type, true); int comma = columnDefinition.indexOf(',', open); if (comma > -1) { // scale and precision - decimal(10,4) int scale = Integer.parseInt(columnDefinition.substring(open + 1, comma)); int precision = Integer.parseInt(columnDefinition.substring(comma + 1, close)); return dbType.renderType(scale, precision) + suffix; } else { // scale - varchar(10) int scale = Integer.parseInt(columnDefinition.substring(open + 1, close)); return dbType.renderType(scale, 0) + suffix; } } catch (IllegalArgumentException e) { // assume already platform specific, leave as is return columnDefinition; } }
String discDbType = dbType.renderType(inheritInfo.getDiscriminatorLength(), 0);