1 | |
package org.paneris.jammyjoes.model; |
2 | |
|
3 | |
import java.sql.ResultSet; |
4 | |
|
5 | |
import org.melati.poem.Database; |
6 | |
import org.melati.poem.DefinitionSource; |
7 | |
import org.melati.poem.PoemException; |
8 | |
import org.paneris.jammyjoes.model.generated.SexTableBase; |
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
public class SexTable extends SexTableBase { |
31 | |
|
32 | |
Sex boy; |
33 | |
Sex girl; |
34 | |
|
35 | |
public SexTable( |
36 | |
Database database, String name, |
37 | |
DefinitionSource definitionSource) throws PoemException { |
38 | 0 | super(database, name, definitionSource); |
39 | 0 | } |
40 | |
|
41 | |
public synchronized void unifyWithDB(ResultSet colDescs) |
42 | |
throws PoemException { |
43 | 0 | super.unifyWithDB(colDescs); |
44 | 0 | boy = ensure("Boy"); |
45 | 0 | girl = ensure("Girl"); |
46 | 0 | } |
47 | |
|
48 | |
public Sex ensure(String s) { |
49 | 0 | Sex sex = (Sex)getSexColumn().firstWhereEq(s); |
50 | 0 | if (sex != null) |
51 | 0 | return sex; |
52 | |
else { |
53 | 0 | sex = (Sex)newPersistent(); |
54 | 0 | sex.setSex(s); |
55 | 0 | return (Sex)getSexColumn().ensure(sex); |
56 | |
} |
57 | |
} |
58 | |
|
59 | |
public Sex getBoy() { |
60 | 0 | return boy; |
61 | |
} |
62 | |
|
63 | |
public Sex getGirl() { |
64 | 0 | return girl; |
65 | |
} |
66 | |
} |