IdEntity.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*******************************************************************************
  2. * Copyright (c) 2005, 2014 springside.github.io
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. *******************************************************************************/
  6. package com.yihu.jw;
  7. import org.hibernate.annotations.GenericGenerator;
  8. import org.springframework.data.annotation.CreatedBy;
  9. import org.springframework.data.annotation.CreatedDate;
  10. import org.springframework.data.annotation.LastModifiedBy;
  11. import org.springframework.data.annotation.LastModifiedDate;
  12. import org.springframework.data.jpa.domain.support.AuditingEntityListener;
  13. import javax.persistence.*;
  14. import java.util.Date;
  15. /**
  16. * 统一定义id的entity基类.
  17. *
  18. * 基类统一定义id的属性名称、数据类型、列名映射及生成策略.
  19. * Oracle需要每个Entity独立定义id的SEQUCENCE时,不继承于本类而改为实现一个Idable的接口。
  20. *
  21. * @author calvin
  22. */
  23. // JPA 基类的标识
  24. @MappedSuperclass
  25. @EntityListeners(AuditingEntityListener.class)
  26. public abstract class IdEntity {
  27. @Id
  28. @GeneratedValue(generator = "uuid")
  29. @GenericGenerator(name = "uuid", strategy = "uuid")
  30. protected String id; // 非业务主键
  31. public String getId() {
  32. return id;
  33. }
  34. public void setId(String id) {
  35. this.id = id;
  36. }
  37. }