View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
3    * not use this file except in compliance with the License. You may obtain a copy of the License at
4    * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
5    * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
6    * implied. See the License for the specific language governing permissions and limitations under the License.
7    */
8   
9   package org.kuali.student.core.entity;
10  
11  import javax.persistence.Embedded;
12  import javax.persistence.MappedSuperclass;
13  
14  import org.kuali.student.common.util.UUIDHelper;
15  
16  @MappedSuperclass
17  public abstract class VersionEntity extends MetaEntity {
18  
19  	@Embedded
20  	private Version version;
21  	
22  	@Override
23  	protected void onPrePersist(){
24  		super.onPrePersist();
25  		if(version == null){
26  			version = new Version();
27  		}
28  		if(version.getSequenceNumber()==null){
29  			version.setSequenceNumber(Long.valueOf(1));
30  		}
31  		version.setVersionIndId(UUIDHelper.genStringUUID(version.getVersionIndId()));
32  	}
33  	
34  	
35  	public Version getVersion() {
36  		return version;
37  	}
38  
39  	public void setVersion(Version version) {
40  		this.version = version;
41  	}
42  }