1 package org.melati.admin.test;
2
3 import org.melati.admin.test.generated.ParentTableBase;
4 import org.melati.poem.DefinitionSource;
5 import org.melati.poem.Database;
6 import org.melati.poem.PoemException;
7
8 /**
9 * Melati POEM generated, programmer modifiable stub
10 * for a <code>ParentTable</code> object.
11 *
12 *
13 * <table>
14 * <caption>
15 * Field summary for SQL table <code>Parent</code>
16 * </caption>
17 * <tr><th>Name</th><th>Type</th><th>Description</th></tr>
18 * <tr><td> id </td><td> Integer </td><td> </td></tr>
19 * <tr><td> name </td><td> String </td><td> </td></tr>
20 * <tr><td> image </td><td> UploadedImage </td><td> </td></tr>
21 * </table>
22 *
23 * See org.melati.poem.prepro.TableDef#generateTableJava
24 */
25 public class ParentTable<T extends Parent> extends ParentTableBase<Parent> {
26
27 /**
28 * Constructor.
29 *
30 * @see org.melati.poem.prepro.TableDef#generateTableJava
31 * @param database the POEM database we are using
32 * @param name the name of this <code>Table</code>
33 * @param definitionSource which definition is being used
34 * @throws PoemException if anything goes wrong
35 */
36 public ParentTable(
37 Database database, String name,
38 DefinitionSource definitionSource) throws PoemException {
39 super(database, name, definitionSource);
40 }
41
42 // programmer's domain-specific code here
43
44 public Parent ensure(String name) {
45 Parent p = (Parent)getNameColumn().firstWhereEq(name);
46 if (p == null) {
47 p = (Parent)newPersistent();
48 p.setName(name);
49 getNameColumn().ensure(p);
50 }
51 return p;
52 }
53
54 }
55