本文整理了Java中javax.persistence.EntityListeners
类的一些代码示例,展示了EntityListeners
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EntityListeners
类的具体详情如下:
包路径:javax.persistence.EntityListeners
类名称:EntityListeners
暂无
代码示例来源:origin: shopizer-ecommerce/shopizer
@Entity
@EntityListeners(value = AuditListener.class)
@Table(name = "PRODUCT_TYPE", schema=SchemaConstant.SALESMANAGER_SCHEMA)
public class ProductType extends SalesManagerEntity<Long, ProductType> implements Auditable {
private static final long serialVersionUID = 65541494628227593L;
@Id
@Column(name = "PRODUCT_TYPE_ID", unique=true, nullable=false)
@TableGenerator(name = "TABLE_GEN", table = "SM_SEQUENCER", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "PRD_TYPE_SEQ_NEXT_VAL")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TABLE_GEN")
private Long id;
private AuditSection auditSection = new AuditSection();
@Column(name = "PRD_TYPE_CODE")
private String code;
@Column(name = "PRD_TYPE_ADD_TO_CART")
private Boolean allowAddToCart;
代码示例来源:origin: hibernate/hibernate-orm
private static void getListeners(XClass currentClazz, List<Class> orderedListeners) {
EntityListeners entityListeners = currentClazz.getAnnotation( EntityListeners.class );
if ( entityListeners != null ) {
Class[] classes = entityListeners.value();
int size = classes.length;
for ( int index = size - 1; index >= 0; index-- ) {
orderedListeners.add( classes[index] );
}
}
if ( useAnnotationAnnotatedByListener ) {
Annotation[] annotations = currentClazz.getAnnotations();
for ( Annotation annot : annotations ) {
entityListeners = annot.getClass().getAnnotation( EntityListeners.class );
if ( entityListeners != null ) {
Class[] classes = entityListeners.value();
int size = classes.length;
for ( int index = size - 1; index >= 0; index-- ) {
orderedListeners.add( classes[index] );
}
}
}
}
}
}
代码示例来源:origin: spring-projects/spring-data-examples
@Entity
@Data
@RequiredArgsConstructor
@EntityListeners(AuditingEntityListener.class)
public class Customer {
private @GeneratedValue @Id Long id;
private @Version Long version;
private @JsonIgnore @LastModifiedDate LocalDateTime lastModifiedDate;
代码示例来源:origin: hibernate/hibernate-orm
@Entity( name = "AnotherEntity" )
@Table( name = "another_entity")
@EntityListeners( AnotherListener.class )
public static class AnotherEntity {
private Integer id;
private String name;
public AnotherEntity() {
}
public AnotherEntity(Integer id) {
this.id = id;
}
@Id
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
代码示例来源:origin: shopizer-ecommerce/shopizer
@MappedSuperclass
@EntityListeners(value = AuditListener.class)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Description implements Auditable, Serializable {
private static final long serialVersionUID = -4335863941736710046L;
@Id
@Column(name = "DESCRIPTION_ID")
@TableGenerator(name = "TABLE_GEN", table = "SM_SEQUENCER", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "DESCRIPTION_SEQ_NEXT_VAL")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TABLE_GEN")
private Long id;
@Column(name="NAME", nullable = false, length=120)
private String name;
@Column(name="TITLE", length=100)
private String title;
代码示例来源:origin: hibernate/hibernate-orm
@Entity
@EntityListeners( LastUpdateListener.class )
public static class Person {
@Id
private Long id;
private String name;
private Date dateOfBirth;
@Transient
private long age;
private Date lastUpdate;
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
/**
* Set the transient property at load time based on a calculation.
* Note that a native Hibernate formula mapping is better for this purpose.
*/
@PostLoad
public void calculateAge() {
age = ChronoUnit.YEARS.between( LocalDateTime.ofInstant(
Instant.ofEpochMilli( dateOfBirth.getTime()), ZoneOffset.UTC),
LocalDateTime.now()
);
}
}
代码示例来源:origin: spring-projects/spring-data-examples
/**
* @author Oliver Gierke
*/
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class AbstractEntity {
@Id @GeneratedValue Long id;
@CreatedDate LocalDateTime createdDate;
@LastModifiedDate LocalDateTime modifiedDate;
}
代码示例来源:origin: hibernate/hibernate-orm
@Entity
@EntityListeners(LastUpdateListener.class)
public class Cat implements Serializable {
private static final Logger log = Logger.getLogger( Cat.class );
代码示例来源:origin: Teradata/kylo
@EntityListeners(AuditTimestampListener.class)
public class AbstractAuditedEntity implements AuditedEntity {
@Column(name = "created_time")
private DateTime createdTime;
@Column(name = "modified_time")
private DateTime modifiedTime;
代码示例来源:origin: kbastani/spring-cloud-event-sourcing-example
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity {
代码示例来源:origin: spring-projects/spring-data-examples
/**
* User domain class that uses auditing functionality of Spring Data that can either be aquired implementing
* {@link Auditable} or extend {@link AbstractAuditable}.
*
* @author Oliver Gierke
* @author Thomas Darimont
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
public class AuditableUser {
private @Id @GeneratedValue Long id;
private String username;
private @CreatedDate LocalDateTime createdDate;
private @LastModifiedDate LocalDateTime lastModifiedDate;
private @ManyToOne @CreatedBy AuditableUser createdBy;
private @ManyToOne @LastModifiedBy AuditableUser lastModifiedBy;
}
代码示例来源:origin: hibernate/hibernate-orm
@Entity
@Table( name = "the_entity")
@EntityListeners( TheListener.class )
public class TheEntity {
private Integer id;
代码示例来源:origin: hibernate/hibernate-demos
@Entity
@EntityListeners(TestListener.class)
public class TestEntity {
@Id
public UUID id;
public String name;
}
代码示例来源:origin: heyuxian/mcloud
@Getter
@Setter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class BaseEntity implements Serializable {
@Id
@GeneratedValue
private Long id;
}
代码示例来源:origin: Teradata/kylo
@EntityListeners(AuditTimestampListener.class)
public class AbstractAuditedEntityAsMillis implements AuditedEntity {
@Column(name = "created_time")
private DateTime createdTime;
@Column(name = "modified_time")
private DateTime modifiedTime;
代码示例来源:origin: kbastani/spring-cloud-event-sourcing-example
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity {
代码示例来源:origin: shopizer-ecommerce/shopizer
@Entity
@EntityListeners(value = AuditListener.class)
@Table(name = "SYSTEM_CONFIGURATION", schema= SchemaConstant.SALESMANAGER_SCHEMA)
public class SystemConfiguration extends SalesManagerEntity<Long, SystemConfiguration> implements Serializable, Auditable {
private static final long serialVersionUID = 6831573162350751684L;
@Id
@Column(name = "SYSTEM_CONFIG_ID")
@TableGenerator(name = "TABLE_GEN", table = "SM_SEQUENCER", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "SYST_CONF_SEQ_NEXT_VAL")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TABLE_GEN")
private Long id;
@Column(name="CONFIG_KEY")
private String key;
@Column(name="VALUE")
private String value;
代码示例来源:origin: spring-projects/spring-framework
@Entity
@EntityListeners(PersonListener.class)
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@EntityListeners(value = { AdminAuditableListener.class })
@Table(name = "BLC_STATIC_ASSET")
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region="blCMSElements")
@AdminPresentationOverrides(
代码示例来源:origin: xwjie/ElementVueSpringbootCodeTemplate
/**
* 基类
*
* @author 肖文杰 https://github.com/xwjie/
*/
@Data
@MappedSuperclass
@EqualsAndHashCode(of = "id")
@EntityListeners(value = JPAListener.class)
public abstract class BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private long id;
@CreationTimestamp
private Date createTime;
@UpdateTimestamp
private Date updateTime;
}
内容来源于网络,如有侵权,请联系作者删除!