View Javadoc

1   package org.kuali.student.common.entity;
2   
3   import javax.persistence.Column;
4   import javax.persistence.Id;
5   import javax.persistence.MappedSuperclass;
6   import javax.persistence.PrePersist;
7   import javax.persistence.PreUpdate;
8   import javax.persistence.Version;
9   
10  import org.kuali.student.common.util.UUIDHelper;
11  
12  @MappedSuperclass
13  public abstract class BaseEntity {
14  	
15  	@Id
16  	@Column(name = "ID")
17  	private String id;
18  	
19  	@Version
20  	@Column(name="VER_NBR")
21  	private Long versionNumber;
22  	
23  	@Column(name="OBJ_ID",length=KSEntityConstants.OBJ_ID_LENGTH)
24  	private String objectId;
25  	
26  	public String getObjectId() {
27  		return objectId;
28  	}
29  
30  	public void setObjectId(String objectId) {
31  		this.objectId = objectId;
32  	}
33  
34  	@PrePersist
35  	public void prePersist(){
36  		//Auto generate the object id, and auto generate the ID if it's not set 
37          this.id = UUIDHelper.genStringUUID(this.id);
38  		this.objectId = UUIDHelper.genStringUUID();
39  		onPrePersist();
40  	}
41  	
42  	@PreUpdate
43  	public void preUpdate(){
44  		onPreUpdate();
45  	}
46  	
47  
48  	//Override this to add additional functionality for the PrePersist Lifecycle
49  	protected void onPrePersist() {
50  	}
51  	
52  	//Override this to add additional functionality for the PreUpdate Lifecycle
53  	protected void onPreUpdate() {
54  	}
55  	
56  	public Long getVersionNumber() {
57  		return versionNumber;
58  	}
59  
60  	public void setVersionNumber(Long versionNumber) {
61  		this.versionNumber = versionNumber;
62  	}
63  
64  	public String getId() {
65  		return id;
66  	}
67  
68  	public void setId(String id) {
69  		this.id = id;
70  	}
71  
72  }