KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > jtrac > domain > SpaceSequence


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package info.jtrac.domain;
18
19 import java.io.Serializable JavaDoc;
20
21 /**
22  * Class that exists purely to denormalize the Space entity in the database.
23  * A Space has a one-to-one relationship with SpaceSequence
24  * Since the "nextSeqNum" property is going to be updated on every new
25  * Item insert, this is kept in a separate "sequence" kind of table to
26  * reduce the number of updates that happen for the Space object / table
27  */

28 public class SpaceSequence implements Serializable JavaDoc {
29     
30     private long id;
31     private long nextSeqNum = 1;
32     
33     public long next() {
34         return nextSeqNum++;
35     }
36     
37     public long getNextSeqNum() {
38         return nextSeqNum;
39     }
40
41     public void setNextSeqNum(long nextSeqNum) {
42         this.nextSeqNum = nextSeqNum;
43     }
44
45     public long getId() {
46         return id;
47     }
48
49     public void setId(long id) {
50         this.id = id;
51     }
52
53 }
54
Popular Tags