本文整理匯總了Java中javax.persistence.DiscriminatorValue.value方法的典型用法代碼示例。如果您正苦於以下問題:Java DiscriminatorValue.value方法的具體用法?Java DiscriminatorValue.value怎麽用?Java DiscriminatorValue.value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.persistence.DiscriminatorValue
的用法示例。
在下文中一共展示了DiscriminatorValue.value方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildDiscriminator
import javax.persistence.DiscriminatorValue; //導入方法依賴的package包/類
private ColumnExpression buildDiscriminator(final EntityClass<?> c, final DiscriminatorColumn column) {
final DiscriminatorType type;
final int maxLength;
if (column == null) {
type = DiscriminatorType.STRING;
final int defaultMaxLength = 31;
maxLength = defaultMaxLength;
} else {
type = column.discriminatorType();
maxLength = column.length();
}
final DiscriminatorValue value = this.entityClass.getAnnotation(DiscriminatorValue.class);
if (type == DiscriminatorType.INTEGER) {
return PrimitiveColumnExpression.create(
value == null ? c.getEntityName().hashCode() : Integer.parseInt(value.value()),
getContext().getDialect());
}
final String v = value == null ? c.getEntityName() : value.value();
if (StringUtils.isEmpty(v)) {
throw new IllegalArgumentException("Missing discriminator value for: " + c.getEntityClass());
}
if (type == DiscriminatorType.STRING) {
return PrimitiveColumnExpression.create(v.length() <= maxLength ? v : v.substring(0, maxLength),
getContext().getDialect());
} else if (type == DiscriminatorType.CHAR) {
return PrimitiveColumnExpression.create(v.substring(0, 1), getContext().getDialect());
}
throw new IllegalArgumentException("Unknown discriminator type: " + type);
}
示例2: getDiscriminatorValue
import javax.persistence.DiscriminatorValue; //導入方法依賴的package包/類
public String getDiscriminatorValue()
{
final DiscriminatorValue annotation = clazz.getAnnotation(DiscriminatorValue.class);
if (annotation != null)
return annotation.value();
else
return clazz.getName();
}