001: /**
002: * Speedo: an implementation of JDO compliant personality on top of JORM generic
003: * I/O sub-system.
004: * Copyright (C) 2001-2004 France Telecom R&D
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: *
021: *
022: * Contact: speedo@objectweb.org
023: *
024: * Authors: S. Chassande-Barrioz
025: *
026: */package org.objectweb.speedo.ejb.pobjects.ref;
027:
028: import javax.persistence.CascadeType;
029: import javax.persistence.Column;
030: import javax.persistence.Entity;
031: import javax.persistence.Id;
032: import javax.persistence.JoinColumn;
033: import javax.persistence.ManyToOne;
034: import javax.persistence.Table;
035:
036: /**
037: * This is an entity that defines an employee. It belongs to a department (see
038: * Departement class). Thus it has a reference to such an entity: this is an
039: * example of unary/unidirectional relationship between Employee and Department.
040: * Used in conjonction with Department.
041: *
042: * @author Y.Bersihand, P. Dechamboux
043: */
044:
045: @Entity
046: @Table(name="EJB_EMPLOYEE")
047: public class Employee {
048: @Id
049: /*TODO (generate=GeneratorType.SEQUENCE,generator="EJB_EMPLOYEESEQ")*/
050: @Column(name="ID")
051: public Long oid;
052: @Column(name="NAME")
053: public String name = null;
054: @Column(name="SALARY")
055: public float salary = 1;
056: @ManyToOne(targetEntity=Department.class,cascade={CascadeType.PERSIST,CascadeType.REFRESH},optional=false)
057: @JoinColumn(name="DEPT",referencedColumnName="ID",nullable=false)
058: public Department dept = null;
059: @ManyToOne(targetEntity=Department.class,cascade={CascadeType.PERSIST,CascadeType.REFRESH},optional=false)
060: @JoinColumn(name="DEPTUNDECL",referencedColumnName="ID",nullable=true)
061: public Department deptundeclared = null;
062: @Column(name="NULLF",length=48)
063: public String nullField = null;
064:
065: public Employee() {
066: }
067:
068: public Employee(String itsName, Department dep) {
069: name = itsName;
070: dept = dep;
071: }
072:
073: public Employee(String itsName, Department dep, float asalary) {
074: name = itsName;
075: dept = dep;
076: salary = asalary;
077: }
078:
079: public long getOid() {
080: return oid;
081: }
082:
083: public void setSalary(float asalary) {
084: salary = asalary;
085: }
086:
087: public String getName() {
088: return name;
089: }
090:
091: public float getSalary() {
092: return salary;
093: }
094:
095: public Department getDept() {
096: return dept;
097: }
098:
099: public Department getDeptundeclared() {
100: return deptundeclared;
101: }
102:
103: public String getNullField() {
104: return nullField;
105: }
106: }
|