IdEntity.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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.wlyy;
  7. import javax.persistence.GeneratedValue;
  8. import javax.persistence.GenerationType;
  9. import javax.persistence.Id;
  10. import javax.persistence.MappedSuperclass;
  11. import java.io.Serializable;
  12. /**
  13. * 统一定义id的entity基类.
  14. *
  15. * 基类统一定义id的属性名称、数据类型、列名映射及生成策略.
  16. * Oracle需要每个Entity独立定义id的SEQUCENCE时,不继承于本类而改为实现一个Idable的接口。
  17. *
  18. * @author calvin
  19. */
  20. // JPA 基类的标识
  21. @MappedSuperclass
  22. public abstract class IdEntity implements Serializable {
  23. private static final long serialVersionUID = 3673803562328635206L;
  24. protected Long id; // 非业务主键
  25. @Id
  26. @GeneratedValue(strategy = GenerationType.IDENTITY)
  27. public Long getId() {
  28. return id;
  29. }
  30. public void setId(Long id) {
  31. this.id = id;
  32. }
  33. }