API Overview API Index Package Overview Direct link to this page
JavaOnTracks 0.1.2
  net.jot.test.db. TestUser View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

/*
------------------------------------
JavaOnTracks          Thibaut Colar
tcolar-jot AT colar DOT net
Artistic Licence 2.0
http://www.javaontracks.net
------------------------------------
 */
package net.jot.test.db;

import net.jot.persistance.JOTModel;
import net.jot.persistance.JOTModelMapping;

/**
 * Internal JOT class for self-test
 * Test user for testing of JOTFS DB implementation
 * @author thibautc
 *
 */
public class TestUser extends JOTModel
{
    // NOTE: must be protected or public

    public String firstName;
    public String lastName;
    public int age;
    //private String fieldToIgnore=null;

    // Required (A model version MUST be defined)
    protected int defineVersion()
    {
        return 1;
    }

    // Required, but can be empty
    public void customize(JOTModelMapping mapping)
    {
        // All the following definitions are optional (example)

        // The name of the table in the database, if different than classname.toLowerCase()
        //mapping.defineTableName("JOT_TMP_TEST_USER");
        // Set the Primary key FB field name (if not 'dataId')
        //mapping.definePrimaryKey("dataid");

        // If you have defined fields in this class that you want to ignore (Not saved in the database table)
        // Note, you should call this very first, preferably.
        //String[] ignore={"fieldToIgnore"};
        //mapping.defineFieldsToIgnore(ignore);

        // For variable-length fields(ie: varchar), you SHOULD define the length
        mapping.defineFieldSize("firstName", 57);
        mapping.defineFieldSize("lastName", 60);

        //Optional definitions examples

        // Field(column) name in DB, if different than fieldname.tolowercase()
        //mapping.defineFieldDBName("firstName", "firstname");

        // Define validation values
        mapping.defineFieldMaxlength("firstName", 20);
        mapping.defineFieldMinlength("firstName", 0);
        mapping.defineFieldMinValue("age", 0);
        mapping.defineFieldMaxValue("age", 130);

    }

    // Required (but can be empty)
    public void upgradeTable(int fromVersion)
    {
    }

//	 for testing purpose we want to reset the table before each run
    public void resetTable() throws Exception
    {
        deleteWholeTable(null, TestUser.class);
    }

    public String toString()
    {
        return "Age: " + age + " ID:" + id + " first:" + firstName + " last:" + lastName;
    }

}

Generated By: JavaOnTracks Doclet 0.1.5     ©Thibaut Colar