| 1 | |
package org.kuali.student.r2.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 | |
|
| 9 | |
import org.kuali.student.common.entity.KSEntityConstants; |
| 10 | |
import org.kuali.student.common.util.UUIDHelper; |
| 11 | |
|
| 12 | |
@MappedSuperclass |
| 13 | 0 | public class BaseEntity { |
| 14 | |
|
| 15 | |
@Id |
| 16 | |
@Column(name = "ID") |
| 17 | |
private String id; |
| 18 | |
@Column(name = "OBJ_ID", length = KSEntityConstants.OBJ_ID_LENGTH) |
| 19 | |
private String objectId; |
| 20 | |
|
| 21 | |
public String getObjectId() { |
| 22 | 0 | return objectId; |
| 23 | |
} |
| 24 | |
|
| 25 | |
public void setObjectId(String objectId) { |
| 26 | 0 | this.objectId = objectId; |
| 27 | 0 | } |
| 28 | |
|
| 29 | |
@PrePersist |
| 30 | |
public void prePersist() { |
| 31 | |
|
| 32 | 0 | if (this.id == null) { |
| 33 | 0 | this.id = UUIDHelper.genStringUUID(this.id); |
| 34 | |
} |
| 35 | 0 | this.objectId = UUIDHelper.genStringUUID(); |
| 36 | 0 | onPrePersist(); |
| 37 | 0 | } |
| 38 | |
|
| 39 | |
@PreUpdate |
| 40 | |
public void preUpdate() { |
| 41 | 0 | onPreUpdate(); |
| 42 | 0 | } |
| 43 | |
|
| 44 | |
|
| 45 | |
protected void onPrePersist() { |
| 46 | 0 | } |
| 47 | |
|
| 48 | |
|
| 49 | |
protected void onPreUpdate() { |
| 50 | 0 | } |
| 51 | |
|
| 52 | |
public String getId() { |
| 53 | 0 | return id; |
| 54 | |
} |
| 55 | |
|
| 56 | |
public void setId(String id) { |
| 57 | 0 | this.id = id; |
| 58 | 0 | } |
| 59 | |
} |