SHOEISHA iD

※旧SEメンバーシップ会員の方は、同じ登録情報(メールアドレス&パスワード)でログインいただけます

CodeZine編集部では、現場で活躍するデベロッパーをスターにするためのカンファレンス「Developers Summit」や、エンジニアの生きざまをブーストするためのイベント「Developers Boost」など、さまざまなカンファレンスを企画・運営しています。

Glenn Paulley氏 データベース関連ブログ 翻訳記事(AD)

SQL AnywhereとPowerDesignerを使ってHibernateスキーマを生成する

原文: Hibernate schema generation using PowerDesigner with SQL Anywhere

  • X ポスト
  • このエントリーをはてなブックマークに追加

 そしてこれに対応するEmployeesクラスのJavaソースコードは次のとおりです。

/***********************************************************************
 * Module:Employees.java
 * Author:paulley
 * Purpose:Defines the Class Employees
 ***********************************************************************/
 
import java.util.*;
 
/** contains information such as names, addresses, salary, hire date, and birthdays of the employees of the sporting goods company
 * 
 * @pdOid da0ef85f-6692-4020-bc97-16a05259f9d4 */
public class Employees implements java.io.Serializable {
   /** @pdOid fa627409-fd02-4d4c-a045-dba3b1d1dfdc */
   public int employeeID;
   /** @pdOid 73cc7b74-ec4e-4802-9a31-dd312394f4e6 */
   public int managerID;
   /** @pdOid e912a688-0b15-47e9-b7ab-c48b5576ca6e */
   public java.lang.String surname;
   /** @pdOid 4bb448a0-2bc3-4a5e-8a1d-5b0847883240 */
   public java.lang.String givenName;
   /** @pdOid 872288ac-db19-4d12-b60a-980791b09590 */
   public java.lang.String street;
   /** @pdOid 146a20a2-dd57-461f-b90f-9705c924c8bd */
   public java.lang.String city;
   /** @pdOid 82a57730-eabc-4340-bed7-3b5adae5d7a2 */
   public java.lang.String state;
   /** @pdOid 124de0c4-86e4-42c8-9293-c35064807eec */
   public java.lang.String country;
   /** @pdOid ad4b7733-0e4b-424b-a21e-ce41c5b8fdb4 */
   public java.lang.String postalCode;
   /** @pdOid 4feb5f1c-e580-4710-8cad-1cfcfcc5ea59 */
   public java.lang.String phone;
   /** @pdOid 8c518d35-b063-4a52-a21b-72657c882ede */
   public java.lang.String status;
   /** @pdOid 204c1cb2-1aef-41bb-a545-2a4ce45001f9 */
   public java.lang.String socialSecurityNumber;
   /** @pdOid acb25f20-f9dc-4537-90b4-0b7d03a6ed95 */
   public double salary;
   /** @pdOid 99ecf548-5b75-4bd3-b6d7-5a5aad5a38c6 */
   public java.util.Date startDate;
   /** @pdOid 7ddeacad-ed35-4c9e-913e-874e51efe72e */
   public java.util.Date terminationDate;
   /** @pdOid 09e0585f-cd1d-4606-a129-f075729e4dea */
   public java.util.Date birthDate;
   /** @pdOid 6fc2ef7d-6178-499a-916c-a821642aa775 */
   public boolean benefitHealthInsurance;
   /** @pdOid 95f6f899-a705-4957-9821-68887b070d44 */
   public boolean benefitLifeInsurance;
   /** @pdOid 0cb88f6e-4179-4cbe-b822-58e1d49abfb0 */
   public boolean benefitDayCare;
   /** @pdOid e63ec90b-2126-4d6c-b670-44355210be53 */
   public java.lang.String sex;
 
   /** @pdRoleInfo migr=no name=Departments assc=fkDepartmentHeadIDEmployeeID coll=java.util.Collection impl=java.util.HashSet mult=0..**/
   public java.util.Collection<Departments> departments;
   /** @pdRoleInfo migr=no name=SalesOrders assc=fkSalesRepresentativeEmployeeID coll=java.util.Collection impl=java.util.HashSet mult=0..**/
   public java.util.Collection<SalesOrders> salesOrders;
   /** @pdRoleInfo migr=no name=Departments assc=fkDepartmentIDDepartmentID mult=1..1 side=A */
   public Departments departments;
 
   /**
    * Empty constructor which is required by Hibernate
    *
    */
   public Employees() {
      // TODO Auto-generated constructor stub
   }
 
   /**
    * @pdGenerated default getter
    */
   public java.util.Collection<Departments> getDepartments() {
      if (departments == null)
         departments = new java.util.HashSet<Departments>();
      return departments;
   }
 
   /**
    * @pdGenerated default iterator getter
    */
   public java.util.Iterator getIteratorDepartments() {
      if (departments == null)
         departments = new java.util.HashSet<Departments>();
      return departments.iterator();
   }
 
   /** 
    * @pdGenerated default setter
    * @param newDepartments
    */
   public void setDepartments(java.util.Collection<Departments> newDepartments) {
      //removeAllDepartments();
      this.departments = newDepartments;   
   }
 
   /** 
    * @pdGenerated default add
    * @param newDepartments
    */
   public void addDepartments(Departments newDepartments) {
      if (newDepartments == null)
         return;
      if (this.departments == null)
         this.departments = new java.util.HashSet<Departments>();
      if (!this.departments.contains(newDepartments))
      {
         this.departments.add(newDepartments);
         newDepartments.setEmployees(this);
      }
   }
 
   /** 
    * @pdGenerated default remove
    * @param oldDepartments
    */
   public void removeDepartments(Departments oldDepartments) {
      if (oldDepartments == null)
         return;
      if (this.departments != null)
         if (this.departments.contains(oldDepartments))
         {
            this.departments.remove(oldDepartments);
            oldDepartments.setEmployees((Employees)null);
         }
   }
 
   /**
    * @pdGenerated default removeAll
    */
   public void removeAllDepartments() {
      if (departments != null)
      {
         Departments oldDepartments;
         for (java.util.Iterator iter = getIteratorDepartments(); iter.hasNext();)
         {
            oldDepartments = (Departments)iter.next();
            iter.remove();
            oldDepartments.setEmployees((Employees)null);
         }
      }
   }
   /**
    * @pdGenerated default getter
    */
   public java.util.Collection<SalesOrders> getSalesOrders() {
      if (salesOrders == null)
         salesOrders = new java.util.HashSet<SalesOrders>();
      return salesOrders;
   }
 
   /**
    * @pdGenerated default iterator getter
    */
   public java.util.Iterator getIteratorSalesOrders() {
      if (salesOrders == null)
         salesOrders = new java.util.HashSet<SalesOrders>();
      return salesOrders.iterator();
   }
 
   /** 
    * @pdGenerated default setter
    * @param newSalesOrders
    */
   public void setSalesOrders(java.util.Collection<SalesOrders> newSalesOrders) {
      //removeAllSalesOrders();
      this.salesOrders = newSalesOrders;   
   }
 
   /** 
    * @pdGenerated default add
    * @param newSalesOrders
    */
   public void addSalesOrders(SalesOrders newSalesOrders) {
      if (newSalesOrders == null)
         return;
      if (this.salesOrders == null)
         this.salesOrders = new java.util.HashSet<SalesOrders>();
      if (!this.salesOrders.contains(newSalesOrders))
      {
         this.salesOrders.add(newSalesOrders);
         newSalesOrders.setEmployees(this);
      }
   }
 
   /** 
    * @pdGenerated default remove
    * @param oldSalesOrders
    */
   public void removeSalesOrders(SalesOrders oldSalesOrders) {
      if (oldSalesOrders == null)
         return;
      if (this.salesOrders != null)
         if (this.salesOrders.contains(oldSalesOrders))
         {
            this.salesOrders.remove(oldSalesOrders);
            oldSalesOrders.setEmployees((Employees)null);
         }
   }
 
   /**
    * @pdGenerated default removeAll
    */
   public void removeAllSalesOrders() {
      if (salesOrders != null)
      {
         SalesOrders oldSalesOrders;
         for (java.util.Iterator iter = getIteratorSalesOrders(); iter.hasNext();)
         {
            oldSalesOrders = (SalesOrders)iter.next();
            iter.remove();
            oldSalesOrders.setEmployees((Employees)null);
         }
      }
   }
   /**
    * @pdGenerated default parent getter
    */
   public Departments getDepartments() {
      return departments;
   }
 
   /**
    * @pdGenerated default parent setter
    * @param newDepartments
    */
   public void setDepartments(Departments newDepartments) {
      if (this.departments == null || !this.departments.equals(newDepartments))
      {
         if (this.departments != null)
         {
            Departments oldDepartments = this.departments;
            this.departments = null;
            //oldDepartments.removeEmployees(this);
         }
         if (newDepartments != null)
         {
            this.departments = newDepartments;
            //this.departments.addEmployees(this);
         }
      }
   }
 
   /**
    * Get value of employeeID
    *
    * @return employeeID 
    */
   public int getEmployeeID()
   {
      return employeeID;
   }
 
   /**
    * Set value of employeeID
    *
    * @param newEmployeeID 
    */
   public void setEmployeeID(int newEmployeeID)
   {
      this.employeeID = newEmployeeID;
   }
 
   /**
    * Get value of managerID
    *
    * @return managerID 
    */
   public int getManagerID()
   {
      return managerID;
   }
 
   /**
    * Set value of managerID
    *
    * @param newManagerID 
    */
   public void setManagerID(int newManagerID)
   {
      this.managerID = newManagerID;
   }
 
   /**
    * Get value of surname
    *
    * @return surname 
    */
   public java.lang.String getSurname()
   {
      return surname;
   }
 
   /**
    * Set value of surname
    *
    * @param newSurname 
    */
   public void setSurname(java.lang.String newSurname)
   {
      this.surname = newSurname;
   }
 
   /**
    * Get value of givenName
    *
    * @return givenName 
    */
   public java.lang.String getGivenName()
   {
      return givenName;
   }
 
   /**
    * Set value of givenName
    *
    * @param newGivenName 
    */
   public void setGivenName(java.lang.String newGivenName)
   {
      this.givenName = newGivenName;
   }
 
   /**
    * Get value of street
    *
    * @return street 
    */
   public java.lang.String getStreet()
   {
      return street;
   }
 
   /**
    * Set value of street
    *
    * @param newStreet 
    */
   public void setStreet(java.lang.String newStreet)
   {
      this.street = newStreet;
   }
 
   /**
    * Get value of city
    *
    * @return city 
    */
   public java.lang.String getCity()
   {
      return city;
   }
 
   /**
    * Set value of city
    *
    * @param newCity 
    */
   public void setCity(java.lang.String newCity)
   {
      this.city = newCity;
   }
 
   /**
    * Get value of state
    *
    * @return state 
    */
   public java.lang.String getState()
   {
      return state;
   }
 
   /**
    * Set value of state
    *
    * @param newState 
    */
   public void setState(java.lang.String newState)
   {
      this.state = newState;
   }
 
   /**
    * Get value of country
    *
    * @return country 
    */
   public java.lang.String getCountry()
   {
      return country;
   }
 
   /**
    * Set value of country
    *
    * @param newCountry 
    */
   public void setCountry(java.lang.String newCountry)
   {
      this.country = newCountry;
   }
 
   /**
    * Get value of postalCode
    *
    * @return postalCode 
    */
   public java.lang.String getPostalCode()
   {
      return postalCode;
   }
 
   /**
    * Set value of postalCode
    *
    * @param newPostalCode 
    */
   public void setPostalCode(java.lang.String newPostalCode)
   {
      this.postalCode = newPostalCode;
   }
 
   /**
    * Get value of phone
    *
    * @return phone 
    */
   public java.lang.String getPhone()
   {
      return phone;
   }
 
   /**
    * Set value of phone
    *
    * @param newPhone 
    */
   public void setPhone(java.lang.String newPhone)
   {
      this.phone = newPhone;
   }
 
   /**
    * Get value of status
    *
    * @return status 
    */
   public java.lang.String getStatus()
   {
      return status;
   }
 
   /**
    * Set value of status
    *
    * @param newStatus 
    */
   public void setStatus(java.lang.String newStatus)
   {
      this.status = newStatus;
   }
 
   /**
    * Get value of socialSecurityNumber
    *
    * @return socialSecurityNumber 
    */
   public java.lang.String getSocialSecurityNumber()
   {
      return socialSecurityNumber;
   }
 
   /**
    * Set value of socialSecurityNumber
    *
    * @param newSocialSecurityNumber 
    */
   public void setSocialSecurityNumber(java.lang.String newSocialSecurityNumber)
   {
      this.socialSecurityNumber = newSocialSecurityNumber;
   }
 
   /**
    * Get value of salary
    *
    * @return salary 
    */
   public double getSalary()
   {
      return salary;
   }
 
   /**
    * Set value of salary
    *
    * @param newSalary 
    */
   public void setSalary(double newSalary)
   {
      this.salary = newSalary;
   }
 
   /**
    * Get value of startDate
    *
    * @return startDate 
    */
   public java.util.Date getStartDate()
   {
      return startDate;
   }
 
   /**
    * Set value of startDate
    *
    * @param newStartDate 
    */
   public void setStartDate(java.util.Date newStartDate)
   {
      this.startDate = newStartDate;
   }
 
   /**
    * Get value of terminationDate
    *
    * @return terminationDate 
    */
   public java.util.Date getTerminationDate()
   {
      return terminationDate;
   }
 
   /**
    * Set value of terminationDate
    *
    * @param newTerminationDate 
    */
   public void setTerminationDate(java.util.Date newTerminationDate)
   {
      this.terminationDate = newTerminationDate;
   }
 
   /**
    * Get value of birthDate
    *
    * @return birthDate 
    */
   public java.util.Date getBirthDate()
   {
      return birthDate;
   }
 
   /**
    * Set value of birthDate
    *
    * @param newBirthDate 
    */
   public void setBirthDate(java.util.Date newBirthDate)
   {
      this.birthDate = newBirthDate;
   }
 
   /**
    * Get value of benefitHealthInsurance
    *
    * @return benefitHealthInsurance 
    */
   public boolean getBenefitHealthInsurance()
   {
      return benefitHealthInsurance;
   }
 
   /**
    * Set value of benefitHealthInsurance
    *
    * @param newBenefitHealthInsurance 
    */
   public void setBenefitHealthInsurance(boolean newBenefitHealthInsurance)
   {
      this.benefitHealthInsurance = newBenefitHealthInsurance;
   }
 
   /**
    * Get value of benefitLifeInsurance
    *
    * @return benefitLifeInsurance 
    */
   public boolean getBenefitLifeInsurance()
   {
      return benefitLifeInsurance;
   }
 
   /**
    * Set value of benefitLifeInsurance
    *
    * @param newBenefitLifeInsurance 
    */
   public void setBenefitLifeInsurance(boolean newBenefitLifeInsurance)
   {
      this.benefitLifeInsurance = newBenefitLifeInsurance;
   }
 
   /**
    * Get value of benefitDayCare
    *
    * @return benefitDayCare 
    */
   public boolean getBenefitDayCare()
   {
      return benefitDayCare;
   }
 
   /**
    * Set value of benefitDayCare
    *
    * @param newBenefitDayCare 
    */
   public void setBenefitDayCare(boolean newBenefitDayCare)
   {
      this.benefitDayCare = newBenefitDayCare;
   }
 
   /**
    * Get value of sex
    *
    * @return sex 
    */
   public java.lang.String getSex()
   {
      return sex;
   }
 
   /**
    * Set value of sex
    *
    * @param newSex 
    */
   public void setSex(java.lang.String newSex)
   {
      this.sex = newSex;
   }
 
   /**
    * Get value of employeesPK.
    *
    * @return employeesPK object
    */
   public EmployeesPK getEmployeesPK() {
      return new EmployeesPK(employeeID);
   }
 
   /**
    * Set value of employeesPK.
    * 
    * @param pk
    */
   public void setEmployeesPK(EmployeesPK pk) {
      if (pk != null) {
         this.employeeID = pk.getEmployeeID();
      }
   }
 
   /* (non-Javadoc)
    * @see java.lang.Object#equals(java.lang.Object)
    */
   public boolean equals(Object other) {
 
      if (other == null)
         return false;
 
      if (other == this)
         return true;   
 
      if (!(other instanceof Employees))
         return false;
 
      Employees cast = (Employees) other;
 
      if (this.employeeID != cast.getEmployeeID())
         return false;
 
      if (this.managerID != cast.getManagerID())
         return false;
 
      if (this.surname == null ? cast.getSurname() != this.surname :!this.surname.equals( cast.getSurname()))
         return false;
 
      if (this.givenName == null ? cast.getGivenName() != this.givenName :!this.givenName.equals( cast.getGivenName()))
         return false;
 
      if (this.street == null ? cast.getStreet() != this.street :!this.street.equals( cast.getStreet()))
         return false;
 
      if (this.city == null ? cast.getCity() != this.city :!this.city.equals( cast.getCity()))
         return false;
 
      if (this.state == null ? cast.getState() != this.state :!this.state.equals( cast.getState()))
         return false;
 
      if (this.country == null ? cast.getCountry() != this.country :!this.country.equals( cast.getCountry()))
         return false;
 
      if (this.postalCode == null ? cast.getPostalCode() != this.postalCode :!this.postalCode.equals( cast.getPostalCode()))
         return false;
 
      if (this.phone == null ? cast.getPhone() != this.phone :!this.phone.equals( cast.getPhone()))
         return false;
 
      if (this.status == null ? cast.getStatus() != this.status :!this.status.equals( cast.getStatus()))
         return false;
 
      if (this.socialSecurityNumber == null ? cast.getSocialSecurityNumber() != this.socialSecurityNumber :!this.socialSecurityNumber.equals( cast.getSocialSecurityNumber()))
         return false;
 
      if (Double.doubleToLongBits(this.salary) != Double.doubleToLongBits(cast.getSalary()))
               return false;
 
      if (this.startDate == null ? cast.getStartDate() != this.startDate :!(com.sybase.orm.util.Util.compareDate(this.startDate,  cast.getStartDate(), java.util.Calendar.SECOND) == 0))
         return false;
 
      if (this.terminationDate == null ? cast.getTerminationDate() != this.terminationDate :!(com.sybase.orm.util.Util.compareDate(this.terminationDate,  cast.getTerminationDate(), java.util.Calendar.SECOND) == 0))
         return false;
 
      if (this.birthDate == null ? cast.getBirthDate() != this.birthDate :!(com.sybase.orm.util.Util.compareDate(this.birthDate,  cast.getBirthDate(), java.util.Calendar.SECOND) == 0))
         return false;
 
      if (this.benefitHealthInsurance != cast.getBenefitHealthInsurance())
         return false;
 
      if (this.benefitLifeInsurance != cast.getBenefitLifeInsurance())
         return false;
 
      if (this.benefitDayCare != cast.getBenefitDayCare())
         return false;
 
      if (this.sex == null ? cast.getSex() != this.sex :!this.sex.equals( cast.getSex()))
         return false;
 
      return true;
   }
 
   /* (non-Javadoc)
    * @see java.lang.Object#hashCode()
    */
   public int hashCode() {
      int hashCode = 0;
      hashCode = 29 * hashCode + (new Integer(employeeID)).hashCode();
      hashCode = 29 * hashCode + (new Integer(managerID)).hashCode();
      if (this.surname != null) 
         hashCode = 29 * hashCode + surname.hashCode();
      if (this.givenName != null) 
         hashCode = 29 * hashCode + givenName.hashCode();
      if (this.street != null) 
         hashCode = 29 * hashCode + street.hashCode();
      if (this.city != null) 
         hashCode = 29 * hashCode + city.hashCode();
      if (this.state != null) 
         hashCode = 29 * hashCode + state.hashCode();
      if (this.country != null) 
         hashCode = 29 * hashCode + country.hashCode();
      if (this.postalCode != null) 
         hashCode = 29 * hashCode + postalCode.hashCode();
      if (this.phone != null) 
         hashCode = 29 * hashCode + phone.hashCode();
      if (this.status != null) 
         hashCode = 29 * hashCode + status.hashCode();
      if (this.socialSecurityNumber != null) 
         hashCode = 29 * hashCode + socialSecurityNumber.hashCode();
      hashCode = 29 * hashCode + (new Double(salary)).hashCode();
      if (this.startDate != null) 
         hashCode = 29 * hashCode + startDate.hashCode();
      if (this.terminationDate != null) 
         hashCode = 29 * hashCode + terminationDate.hashCode();
      if (this.birthDate != null) 
         hashCode = 29 * hashCode + birthDate.hashCode();
      hashCode = 29 * hashCode + (new Boolean(benefitHealthInsurance)).hashCode();
      hashCode = 29 * hashCode + (new Boolean(benefitLifeInsurance)).hashCode();
      hashCode = 29 * hashCode + (new Boolean(benefitDayCare)).hashCode();
      if (this.sex != null) 
         hashCode = 29 * hashCode + sex.hashCode();
      return hashCode;
   }
 
   /* (non-Javadoc)
    * @see java.lang.Object#toString()
    */
   public String toString()
   {
      StringBuffer ret = new StringBuffer();
      ret.append( "Employees:" );
      ret.append( "employeeID='" + employeeID + "'");
      ret.append( "managerID='" + managerID + "'");
      ret.append( "surname='" + surname + "'");
      ret.append( "givenName='" + givenName + "'");
      ret.append( "street='" + street + "'");
      ret.append( "city='" + city + "'");
      ret.append( "state='" + state + "'");
      ret.append( "country='" + country + "'");
      ret.append( "postalCode='" + postalCode + "'");
      ret.append( "phone='" + phone + "'");
      ret.append( "status='" + status + "'");
      ret.append( "socialSecurityNumber='" + socialSecurityNumber + "'");
      ret.append( "salary='" + salary + "'");
      ret.append( "startDate='" + startDate + "'");
      ret.append( "terminationDate='" + terminationDate + "'");
      ret.append( "birthDate='" + birthDate + "'");
      ret.append( "benefitHealthInsurance='" + benefitHealthInsurance + "'");
      ret.append( "benefitLifeInsurance='" + benefitLifeInsurance + "'");
      ret.append( "benefitDayCare='" + benefitDayCare + "'");
      ret.append( "sex='" + sex + "'");
      return ret.toString();
   }
 
}

この記事は参考になりましたか?

  • X ポスト
  • このエントリーをはてなブックマークに追加
Glenn Paulley氏 データベース関連ブログ 翻訳記事連載記事一覧

もっと読む

この記事の著者

Glenn Paulley(Glenn Paulley)

カナダ オンタリオ州 ウォータールー R&DセンターにてSQL Anywhere 開発における Director of Engineering としてクエリ・オプティマイザなどの開発をリードしている。・IvanAnywhere

※プロフィールは、執筆時点、または直近の記事の寄稿時点での内容です

【AD】本記事の内容は記事掲載開始時点のものです 企画・制作 株式会社翔泳社

この記事は参考になりましたか?

この記事をシェア

  • X ポスト
  • このエントリーをはてなブックマークに追加
CodeZine(コードジン)
https://codezine.jp/article/detail/5624 2011/06/09 13:01

おすすめ

アクセスランキング

アクセスランキング

イベント

CodeZine編集部では、現場で活躍するデベロッパーをスターにするためのカンファレンス「Developers Summit」や、エンジニアの生きざまをブーストするためのイベント「Developers Boost」など、さまざまなカンファレンスを企画・運営しています。

新規会員登録無料のご案内

  • ・全ての過去記事が閲覧できます
  • ・会員限定メルマガを受信できます

メールバックナンバー

アクセスランキング

アクセスランキング