本文整理汇总了Java中javax.persistence.Column.length方法的典型用法代码示例。如果您正苦于以下问题:Java Column.length方法的具体用法?Java Column.length怎么用?Java Column.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.Column
的用法示例。
在下文中一共展示了Column.length方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLength
import javax.persistence.Column; //导入方法依赖的package包/类
/**
* @return Length to be used for varchar (or string) data type.
*/
public Integer getLength() {
if (genInfo.getCategory() == TypeDescription.Category.CHAR) {
return 1;
} else if (!GeneratorUtil.isSupportsLengthSpecification(genInfo.getCategory())) {
return null;
}
Orc orc = genInfo.getAnnotation(Orc.class);
if (orc == null) {
// Check if jpa column annotation is present.
Column col = genInfo.getAnnotation(Column.class);
if (col == null || col.length() == 0) {
return null;
}
return col.length();
}
return orc.length() == 0 ? null : orc.length();
}
示例2: _getCategory
import javax.persistence.Column; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected Category _getCategory(Class<?> clz) {
if (clz == null) {
return Category.STRUCT;
} else if (GeneratorUtil.getCategoryByBasicType(clz) != null) {
return GeneratorUtil.getCategoryByBasicType(clz);
} else if (String.class.isAssignableFrom(clz)) {
// Return STRING vs VARCHAR based on whether size is specified or not.
Orc orc = getAnnotation(Orc.class);
if (orc == null) {
// Check if jpa column annotation is present.
Column col = getAnnotation(Column.class);
if (col == null || col.length() == 0) {
return Category.STRING;
}
return Category.VARCHAR;
}
return orc.length() == 0 ? Category.STRING : Category.VARCHAR;
} else if (GeneratorUtil.getCategoryByAssignableType(clz) != null) {
Category category = GeneratorUtil.getCategoryByAssignableType(clz);
return category == Category.TIMESTAMP ? getAnnotationBasedDateCategory() : category;
} else if (Enum.class.isAssignableFrom(clz)) {
return getEnumCategory((Class<? extends Enum<?>>) clz);
}
return Category.STRUCT;
}
示例3: getSqlType
import javax.persistence.Column; //导入方法依赖的package包/类
static String getSqlType(Field f) {
String t = typeMapping.get(f.getType());
if (t != null) {
return t;
}
if (f.getType().equals(String.class)) {
Column c = f.getAnnotation(Column.class);
int length = c == null ? 255 : c.length();
return "VARCHAR(" + length + ")";
}
throw new IllegalArgumentException("Unsupported type: " + f.getType().getName() + " of field: " + f.getName());
}