001: package example;
002:
003: import java.util.Collection;
004:
005: import javax.persistence.*;
006:
007: /**
008: * Implementation class for the Student bean.
009: *
010: * <code><pre>
011: * CREATE TABLE amber_query_student (
012: * id INTEGER PRIMARY KEY auto_increment,
013: * name VARCHAR(250),
014: * gender VARCHAR(1),
015: * house INTEGER
016: * );
017: * </pre></code>
018: */
019: @Entity
020: @Table(name="amber_query_student")
021: public class Student {
022: private long _id;
023: private String _name;
024: private String _gender;
025: private House _house;
026:
027: public Student() {
028: }
029:
030: public Student(String name, String gender, House house) {
031: setName(name);
032: setGender(gender);
033: setHouse(house);
034: }
035:
036: /**
037: * Gets the id.
038: */
039: @Id
040: @Column(name="id")
041: @GeneratedValue
042: public long getId() {
043: return _id;
044: }
045:
046: /**
047: * Sets the id.
048: */
049: public void setId(long id) {
050: _id = id;
051: }
052:
053: /**
054: * Returns the name of the student.
055: */
056: @Basic
057: @Column(unique=true)
058: public String getName() {
059: return _name;
060: }
061:
062: /**
063: * Sets the name of the student.
064: */
065: public void setName(String name) {
066: _name = name;
067: }
068:
069: /**
070: * Returns the gender of the student.
071: */
072: @Basic
073: @Column(length=1)
074: public String getGender() {
075: return _gender;
076: }
077:
078: /**
079: * Sets the gender of the student.
080: */
081: public void setGender(String gender) {
082: _gender = gender;
083: }
084:
085: /**
086: * Returns the <code>House</code> that this Student belongs to.
087: */
088: @ManyToOne
089: @JoinColumn(name="house")
090: public House getHouse() {
091: return _house;
092: }
093:
094: /**
095: * Sets the <code>House</code> this Student belongs to.
096: */
097: public void setHouse(House house) {
098: _house = house;
099: }
100: }
|