01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
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 {
29:
30: private long id;
31: private long nextSeqNum = 1;
32: private Space space;
33:
34: public long next() {
35: return nextSeqNum++;
36: }
37:
38: public long getNextSeqNum() {
39: return nextSeqNum;
40: }
41:
42: public void setNextSeqNum(long nextSeqNum) {
43: this .nextSeqNum = nextSeqNum;
44: }
45:
46: public long getId() {
47: return id;
48: }
49:
50: public void setId(long id) {
51: this .id = id;
52: }
53:
54: public Space getSpace() {
55: return space;
56: }
57:
58: public void setSpace(Space space) {
59: this.space = space;
60: }
61:
62: }
|