javax.persistence.Inheritance.strategy()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中javax.persistence.Inheritance.strategy()方法的一些代码示例,展示了Inheritance.strategy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Inheritance.strategy()方法的具体详情如下:
包路径:javax.persistence.Inheritance
类名称:Inheritance
方法名:strategy

Inheritance.strategy介绍

暂无

代码示例

代码示例来源:origin: hibernate/hibernate-orm

private void extractInheritanceType() {
  XAnnotatedElement element = getClazz();
  Inheritance inhAnn = element.getAnnotation( Inheritance.class );
  MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class );
  if ( mappedSuperClass != null ) {
    setEmbeddableSuperclass( true );
    setType( inhAnn == null ? null : inhAnn.strategy() );
  }
  else {
    setType( inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy() );
  }
}

代码示例来源:origin: hector-client/hector

private <T> void parseInheritanceAnnotation(Inheritance anno, CFMappingDef<T> cfMapDef) {
 if (InheritanceType.SINGLE_TABLE == anno.strategy()) {
  cfMapDef.setInheritanceType(InheritanceType.SINGLE_TABLE);
 } else {
  throw new RuntimeException("Hector object mapper only supports "
    + InheritanceType.SINGLE_TABLE + " inheritance at the moment");
 }
}

代码示例来源:origin: org.hibernate/hibernate-annotations

private void extractInheritanceType() {
  XAnnotatedElement element = getClazz();
  Inheritance inhAnn = element.getAnnotation( Inheritance.class );
  MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class );
  if ( mappedSuperClass != null ) {
    setEmbeddableSuperclass( true );
    setType( inhAnn == null ? null : inhAnn.strategy() );
  }
  else {
    setType( inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy() );
  }
}

代码示例来源:origin: Impetus/Kundera

InheritanceType strategyType = inheritenceAnn.strategy();

代码示例来源:origin: ebean-orm/ebean

private DeployInheritInfo createInfo(Class<?> cls) {
 DeployInheritInfo info = new DeployInheritInfo(cls);
 Class<?> parent = findParent(cls);
 if (parent != null) {
  info.setParent(parent);
 }
 Inheritance ia = AnnotationUtil.findAnnotationRecursive(cls, Inheritance.class);
 if (ia != null) {
  ia.strategy();
 }
 DiscriminatorColumn da = AnnotationUtil.findAnnotationRecursive(cls, DiscriminatorColumn.class);
 if (da != null) {
  // lowercase the discriminator column for RawSql and JSON
  info.setColumnName(da.name().toLowerCase());
  info.setColumnType(da.discriminatorType());
  info.setColumnLength(da.length());
  info.setColumnDefn(da.columnDefinition());
 }
 if (!info.isAbstract()) {
  DiscriminatorValue dv = AnnotationUtil.findAnnotation(cls, DiscriminatorValue.class); // do not search recursive
  if (dv != null) {
   info.setDiscriminatorValue(dv.value());
  } else {
   info.setDiscriminatorValue(cls.getSimpleName());
  }
 }
 return info;
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

private void extractInheritanceType() {
  XAnnotatedElement element = clazz;
  Inheritance inhAnn = element.getAnnotation( Inheritance.class );
  MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class );
  if ( mappedSuperClass != null ) {
    isEmbeddableSuperclass = true;
    type = inhAnn == null ? null : inhAnn.strategy();
  }
  else {
    type = inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy();
  }
}

代码示例来源:origin: riptano/hector-jpa

/**
 * Parse the cassandra index expression
 * 
 * @param fmd
 * @param index
 */
private void handleInheritance(CassandraClassMetaData cass,
  Inheritance inheritance) {
 if (inheritance.strategy() != InheritanceType.SINGLE_TABLE) {
  throw new MetaDataException("Only single table inheritance is supported");
 }
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

protected String getEntityNameForIdGeneration(MetaClass metaClass) {
  List<MetaClass> persistentAncestors = metaClass.getAncestors().stream()
      .filter(mc -> tools.isPersistent(mc)) // filter out all mapped superclasses
      .collect(Collectors.toList());
  if (persistentAncestors.size() > 0) {
    MetaClass root = persistentAncestors.get(persistentAncestors.size() - 1);
    Class<?> javaClass = root.getJavaClass();
    Inheritance inheritance = javaClass.getAnnotation(Inheritance.class);
    if (inheritance == null || inheritance.strategy() != InheritanceType.TABLE_PER_CLASS) {
      // use root of inheritance tree if the strategy is JOINED or SINGLE_TABLE because ID is stored in the root table
      return root.getName();
    }
  }
  return metaClass.getName();
}

代码示例来源:origin: toplink.essentials/toplink-essentials

/**
 * INTERNAL: (Overridden in XMLClassAccessor)
 * Return the inheritance strategy. This method should only be called
 * on the root of the inheritance hierarchy.
 */
protected String getInheritanceStrategy() {
  Inheritance inheritance = getAnnotation(Inheritance.class);
  
  if (inheritance == null) {
    return "";
  } else {
    return inheritance.strategy().name();   
  }
}

代码示例来源:origin: org.hibernate.orm/hibernate-core

private void extractInheritanceType() {
  XAnnotatedElement element = getClazz();
  Inheritance inhAnn = element.getAnnotation( Inheritance.class );
  MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class );
  if ( mappedSuperClass != null ) {
    setEmbeddableSuperclass( true );
    setType( inhAnn == null ? null : inhAnn.strategy() );
  }
  else {
    setType( inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy() );
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

private void extractInheritanceType() {
  XAnnotatedElement element = getClazz();
  Inheritance inhAnn = element.getAnnotation( Inheritance.class );
  MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class );
  if ( mappedSuperClass != null ) {
    setEmbeddableSuperclass( true );
    setType( inhAnn == null ? null : inhAnn.strategy() );
  }
  else {
    setType( inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy() );
  }
}

代码示例来源:origin: org.codehaus.castor/castor-jdo

InheritanceType strategy = inheritance.strategy();

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

private void extractInheritanceType() {
  XAnnotatedElement element = getClazz();
  Inheritance inhAnn = element.getAnnotation( Inheritance.class );
  MappedSuperclass mappedSuperClass = element.getAnnotation( MappedSuperclass.class );
  if ( mappedSuperClass != null ) {
    setEmbeddableSuperclass( true );
    setType( inhAnn == null ? null : inhAnn.strategy() );
  }
  else {
    setType( inhAnn == null ? InheritanceType.SINGLE_TABLE : inhAnn.strategy() );
  }
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

/**
 * Parse @Inheritance.
 */
private void parseInheritance(ClassMapping cm, Inheritance inherit) {
  ClassMappingInfo info = cm.getMappingInfo();
  switch (inherit.strategy()) {
    case SINGLE_TABLE:
      info.setHierarchyStrategy(FlatClassStrategy.ALIAS);
      break;
    case JOINED:
      info.setHierarchyStrategy(VerticalClassStrategy.ALIAS);
      break;
    case TABLE_PER_CLASS:
      info.setHierarchyStrategy(FullClassStrategy.ALIAS);
      break;
    default:
      throw new InternalException();
  }
}

代码示例来源:origin: org.apache.openjpa/openjpa-persistence-jdbc

/**
 * Parse @Inheritance.
 */
private void parseInheritance(ClassMapping cm, Inheritance inherit) {
  ClassMappingInfo info = cm.getMappingInfo();
  switch (inherit.strategy()) {
    case SINGLE_TABLE:
      info.setHierarchyStrategy(FlatClassStrategy.ALIAS);
      break;
    case JOINED:
      info.setHierarchyStrategy(VerticalClassStrategy.ALIAS);
      break;
    case TABLE_PER_CLASS:
      info.setHierarchyStrategy(FullClassStrategy.ALIAS);
      break;
    default:
      throw new InternalException();
  }
}

代码示例来源:origin: org.apache.openjpa/com.springsource.org.apache.openjpa

/**
 * Parse @Inheritance.
 */
private void parseInheritance(ClassMapping cm, Inheritance inherit) {
  ClassMappingInfo info = cm.getMappingInfo();
  switch (inherit.strategy()) {
    case SINGLE_TABLE:
      info.setHierarchyStrategy(FlatClassStrategy.ALIAS);
      break;
    case JOINED:
      info.setHierarchyStrategy(VerticalClassStrategy.ALIAS);
      break;
    case TABLE_PER_CLASS:
      info.setHierarchyStrategy(FullClassStrategy.ALIAS);
      break;
    default:
      throw new InternalException();
  }
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

/**
 * Parse @Inheritance.
 */
private void parseInheritance(ClassMapping cm, Inheritance inherit) {
  ClassMappingInfo info = cm.getMappingInfo();
  switch (inherit.strategy()) {
    case SINGLE_TABLE:
      info.setHierarchyStrategy(FlatClassStrategy.ALIAS);
      break;
    case JOINED:
      info.setHierarchyStrategy(VerticalClassStrategy.ALIAS);
      break;
    case TABLE_PER_CLASS:
      info.setHierarchyStrategy(FullClassStrategy.ALIAS);
      break;
    default:
      throw new InternalException();
  }
}

代码示例来源:origin: org.avaje/ebean

private DeployInheritInfo createInfo(Class<?> cls) {
  DeployInheritInfo info = new DeployInheritInfo(cls);
  Class<?> parent = findParent(cls);
  if (parent != null) {
    info.setParent(parent);
  } else {
    // its the root of inheritance tree...
  }
  Inheritance ia = (Inheritance) cls.getAnnotation(Inheritance.class);
  if (ia != null) {
    ia.strategy();
  }
  DiscriminatorColumn da = (DiscriminatorColumn) cls.getAnnotation(DiscriminatorColumn.class);
  if (da != null) {
    info.setDiscriminatorColumn(da.name());
    DiscriminatorType discriminatorType = da.discriminatorType();
    if (discriminatorType.equals(DiscriminatorType.INTEGER)){
      info.setDiscriminatorType(Types.INTEGER);                
    } else {
      info.setDiscriminatorType(Types.VARCHAR);
    }
    info.setDiscriminatorLength(da.length());
  }
  DiscriminatorValue dv = (DiscriminatorValue) cls.getAnnotation(DiscriminatorValue.class);
  if (dv != null) {
    info.setDiscriminatorValue(dv.value());
  }
  
  return info;
}

代码示例来源:origin: io.ebean/ebean

private DeployInheritInfo createInfo(Class<?> cls) {
 DeployInheritInfo info = new DeployInheritInfo(cls);
 Class<?> parent = findParent(cls);
 if (parent != null) {
  info.setParent(parent);
 }
 Inheritance ia = AnnotationUtil.findAnnotationRecursive(cls, Inheritance.class);
 if (ia != null) {
  ia.strategy();
 }
 DiscriminatorColumn da = AnnotationUtil.findAnnotationRecursive(cls, DiscriminatorColumn.class);
 if (da != null) {
  // lowercase the discriminator column for RawSql and JSON
  info.setColumnName(da.name().toLowerCase());
  info.setColumnType(da.discriminatorType());
  info.setColumnLength(da.length());
  info.setColumnDefn(da.columnDefinition());
 }
 if (!info.isAbstract()) {
  DiscriminatorValue dv = AnnotationUtil.findAnnotation(cls, DiscriminatorValue.class); // do not search recursive
  if (dv != null) {
   info.setDiscriminatorValue(dv.value());
  } else {
   info.setDiscriminatorValue(cls.getSimpleName());
  }
 }
 return info;
}

代码示例来源:origin: org.avaje.ebean/ebean

private DeployInheritInfo createInfo(Class<?> cls) {
 DeployInheritInfo info = new DeployInheritInfo(cls);
 Class<?> parent = findParent(cls);
 if (parent != null) {
  info.setParent(parent);
 }
 Inheritance ia = AnnotationBase.findAnnotation(cls,Inheritance.class);
 if (ia != null) {
  ia.strategy();
 }
 DiscriminatorColumn da = AnnotationBase.findAnnotation(cls,DiscriminatorColumn.class);
 if (da != null) {
  // lowercase the discriminator column for RawSql and JSON
  info.setDiscriminatorColumn(da.name().toLowerCase());
  DiscriminatorType discriminatorType = da.discriminatorType();
  if (discriminatorType.equals(DiscriminatorType.INTEGER)) {
   info.setDiscriminatorType(Types.INTEGER);
  } else {
   info.setDiscriminatorType(Types.VARCHAR);
  }
  info.setDiscriminatorLength(da.length());
 }
 DiscriminatorValue dv = AnnotationBase.findAnnotation(cls,DiscriminatorValue.class);
 if (dv != null) {
  info.setDiscriminatorValue(dv.value());
 }
 return info;
}

相关文章