javax.persistence.Inheritance类的使用及代码示例

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

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

Inheritance介绍

暂无

代码示例

代码示例来源:origin: ctripcorp/apollo

@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class BaseEntity {
 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 @Column(name = "Id")
 private long id;
 @Column(name = "IsDeleted", columnDefinition = "Bit default '0'")
 protected boolean isDeleted = false;
 @Column(name = "DataChange_CreatedBy", nullable = false)
 private String dataChangeCreatedBy;

代码示例来源: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: hibernate/hibernate-orm

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(schema = "schema1", name = "entity")
public static class Entity1 {
  private String id;
  @Id
  public String getId() {
    return id;
  }
  public void setId(String id) {
    this.id = id;
  }
}

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

@Entity(name = "BuildingListEntry")
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "TB_BUILDING_LIST_ENTRY")
public static class BuildingListEntry extends DBObject implements Serializable {
  @Column
  protected String comments;
  @Column
  protected Integer priority;
  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "list_id")
  protected BuildingList list;
  public String getComments() {
    return comments;
  }
  public void setComments(String comments) {
    this.comments = comments;
  }
  public Integer getPriority() {
    return priority;
  }
  public void setPriority(Integer priority) {
    this.priority = priority;
  }
  public BuildingList getList() {
    return list;
  }
  public void setList(BuildingList list) {
    this.list = list;
  }
}

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

/**
 * @author Andrea Boriero
 */

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Mammal extends Animal {

  @Column(name = "IS_PREGNANT")
  @Type(type = "numeric_boolean")
  private boolean isPregnant;

  public boolean isPregnant() {
    return isPregnant;
  }

  public void setPregnant(boolean isPregnant) {
    this.isPregnant = isPregnant;
  }
}

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

@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@MappedSuperclass
public static class Employee {
  @Id
  @GeneratedValue
  private Long id;
  private String jobType;
  private String firstName;
  private String lastName;
}

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

/**
 * @author Andrea Boriero
 */
@javax.persistence.Entity
@Inheritance(strategy = InheritanceType.JOINED)
public interface TestEntityInterface extends Common {
}

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

InheritanceType strategyType = inheritenceAnn.strategy();
  tableName = superClazzType.getJavaType().getAnnotation(Table.class).name();
  schemaName = superClazzType.getJavaType().getAnnotation(Table.class).schema();

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

/**
 * The intermediate entity in the hierarchy
 *
 * @author Saša Obradović
 */
@Entity
@Table(name = "`ACCOUNT`")
@Inheritance(strategy = InheritanceType.JOINED)
public class Account extends AccountBase {
  public Account() {
  }

  public Account(String accountNumber) {
    super( accountNumber );
  }
}

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

@Entity(name = "BuildingList")
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "TB_BUILDING_LIST")
@SequenceGenerator(name = "seq",
    sequenceName = "sq_building_list_id",
    allocationSize = 1)
public static class BuildingList extends DBObject implements Serializable {
  @Column
  private String name;
  @OneToMany(cascade = CascadeType.ALL, mappedBy = "list")
  private Collection<BuildingListEntry> entries = new ArrayList<>();
  public String getName() {
    return name;
  }
  public void setName(String name) {
    this.name = name;
  }
  public Collection<BuildingListEntry> getEntries() {
    return entries;
  }
  public void setEntries(Collection<BuildingListEntry> entries) {
    this.entries = entries;
  }
}

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

/**
 * Entity having a many to one in its pk
 *
 * @author Emmanuel Bernard
 */
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class Child {
  @EmbeddedId
  @AttributeOverride(name = "nthChild", column = @Column(name = "nth"))
  public ChildPk id;
}

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

@MappedSuperclass
@Inheritance( strategy = InheritanceType.SINGLE_TABLE )
@DiscriminatorColumn( name = "type", discriminatorType = DiscriminatorType.STRING )
private static abstract class Item {
  @Id
  @GeneratedValue
  Long id;
  @ManyToOne( fetch = FetchType.LAZY )
  Author author;
}

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

@Entity(name = "Vehicle")
@Inheritance( strategy = InheritanceType.JOINED )
public static class Vehicle {
  @EmbeddedId
  public VehicleId id;
}

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

@Entity(name = "InheritanceRootEntity")
@Table(name = "InheritanceRootEntity", catalog = "hibernate_orm_test_collation", schema = "dbo")
@Inheritance(strategy = InheritanceType.JOINED)
public static class InheritanceRootEntity {
  @Id
  protected Long id;
}

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

/**
 * Test entities ANN-730.
 * 
 * @author Hardy Ferentschik
 * 
 */
@Entity
@Table(name = "class_a")
@Inheritance(strategy = InheritanceType.JOINED)
public class ClassA {

  private int id;

  @Id
  @Column(name = "id")
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@EntityListeners(value = { AdminAuditableListener.class })
@Table(name = "BLC_IMG_STATIC_ASSET")
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region="blCMSElements")
public class ImageStaticAssetImpl extends StaticAssetImpl implements ImageStaticAsset {
  @Column(name ="WIDTH")
  @AdminPresentation(friendlyName = "ImageStaticAssetImpl_Width",
      order = FieldOrder.LAST + 1000,
  protected Integer width;
  @Column(name ="HEIGHT")
  @AdminPresentation(friendlyName = "ImageStaticAssetImpl_Height",
      order = FieldOrder.LAST + 2000,

代码示例来源: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: hibernate/hibernate-orm

@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Entity(name = "Vehicle")
public static class Vehicle {
  @Id
  @GeneratedValue
  private Long id;
  private String name;
}

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

/**
 * @author Emmanuel Bernard
 */
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "TBLASSET")
public class Asset {
  private Integer id;

  private Parent parent = null;

  @Id @GeneratedValue public Integer getId() {
    return id;
  }

  public void setId(Integer id) {
    this.id = id;
  }

  @ManyToOne(targetEntity = Parent.class)
  @JoinColumn(name = "PARENTID")
  public Parent getParent() {
    return parent;
  }

  public void setParent(Parent parent) {
    this.parent = parent;
  }
}

代码示例来源: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() );
  }
}

相关文章