本稿はデータベースソフトウェア「SQL Anywhere」およびデータベース全般に関する英語ドキュメントを翻訳する形で提供しています。図など、部分的に英語のままになっていますが、製品のSQL Anywhere自体は完全に日本語化されていますのでご安心ください。
私はいくつか前の投稿で、SQL AnywhereのデータベースをリバースエンジニアすることでHibernateの設定ファイルとそれに対応するJavaクラスを生成する方法について述べました。そのときに使ったのは、既に廃止されたMiddlegenとAnt、そしてEclipse GanymedeからHibernate Toolsのプラグインを利用するやり方です。
私の経験から言うと、MiddlegenもHibernate Toolsのプラグインも、とりわけ堅牢なツールというわけではありません。Middlegenのソフトウェアは今や過去のものです。またHibernate ToolsのプラグインはEclipseを必要としますが、Eclipseの使用環境のセットアップは驚くほど厄介なものです(たまたま私にとってそうだったという可能性もありますが、おそらく違うでしょう)。さらに、セットアップの過程で少しでも間違いがあると、Hibernate Toolsのプラグインは無益な(もしくは誤った)挙動をするようになります。
そこでこの投稿では、代わりにSybase PowerDesigner 15.2(注:日本語版はなくサイベース日本法人での国内正式提供はないため要問合せ)を利用する方法を紹介します。PowerDesignerはバージョン11以来、Hibernateをサポートしてきました。(この時点で)最新のリリースであるPowerDesigner 15.2(ちなみにPowerDesigner 15.2 EBFはリリース間近のSQL Anywhere 12をサポート予定)は、HibernateとNHibernateの''両方''のリバースエンジニアリングをサポートします。これにより、該当するC#もしくはJavaのクラスファイルを作成することができます。
しかし悲しいかな、SQL Anywhereのパッケージに無料で含まれるPowerDesigner Physical Modeler(注:日本では現在ライセンス/サポートしていません)はHibernateをサポートしていません。PowerDesignerのフルバージョンにのみHibernateとNHibernateの拡張機能がついてきます。しかしながら、HibernateやNHibernateを使ってSQL Anywhereのアプリケーションを開発している方は、作業の効率化のためPowerDesignerの購入を検討するべきだと思います。PowerDesignerのHibernateサポートは実に優秀だからです。
Javaのリバースエンジニアリング
ここではSQL Anywhere 12リリース候補版のサーバー上で作動している「デモ」データベースを例に、PowerDesigner 15.2のHibernate機能を解説します。サーバーとPowerDesignerを起動した後、PowerDesignerのリバースエンジニアリング機能を使ってデモデータベースの物理モデルを作成しました。[File]→[Reverse engineer]→[Database link]という手順です。デモデータベース内でGROUPOユーザーが所有しているテーブルは、Employees、Parts、Orders、Departmentsといったおなじみのテーブルで、スキーマの大部分を占めます。リバースエンジニアリングダイアログから、これらを除くすべての項目のチェックを解除しました。
先ほどは物理モデルを作成しましたが、今度はその物理モデルのオブジェクト指向モデルを構築しなければなりません。これにより、必要となるHibernateアーティファクトを作り出すことができます。この作業をアシストするウィザードがあり、[Tools]→[Generate Object-Oriented Model]から開始できます。その結果、以下のようなダイアログが表示されます。
オブジェクト言語として[Java]を選択し、モデルの名前をデフォルト(大文字の物理モデルの名前)から「Java model」に変更します。これでオブジェクト指向のモデルができました。Hibernateオブジェクトの生成を可能にするためには、Hibernateモデルエクステンションでオブジェクト指向モデルを拡張する必要があります。[Model]→[Extended Model Definitions]を選択するとモデルエクステンションのリストが提示されます。ダイアログ上部にあるアイコンのうち右から2番目([Import an extended model definition])をクリックすると以下のダイアログが表示されます。
ここで[Hibernate]を選択します。この時点で、必要なJavaファイルまたはHibernateファイル(もしくはその両方)をPowerDesignerに生成させることが可能になります。注意してほしいのは、Hibernateの方言やその他の設定パラメータをまだ指定していないということです。HibernateのマッピングファイルとJavaのPOJOコードを生成する機能はPowerDesignerにビルトインされています(ちなみに、これらの情報を後で指定して、PowerDesignerにアプリケーション用のテストストリームを自動生成させることもできます。これについては後日の投稿で取り上げるかもしれません)。
JavaコードとHibernateファイルの生成には、メニューから[Language]→[Generate Java Code]を選択します。そのとき、以下の設定ダイアログが表示されます。
上記のスクリーンショットでは、生成される一群のJavaクラスが表示されています。ダイアログ内の他のタブではさまざまなアーティファクト、特にHibernateマッピングファイルを指定することができます。注意が必要なのは、ファイルの生成場所(つまりディレクトリ)の指定です。ダイアログ上部のディレクトリ名のフィールドを空欄にしないよう気をつけてください。ここにはアプリケーションのルートディレクトリを指定する必要があります。このダイアログでは、PowerDesignerによって生成される特定のタイプのオブジェクトについてのディレクトリ指定を含めることができますが、指定した名前は「ルート」ディレクトリの後に''連結''されます。もし間違った絶対パスを指定した場合は(実際、私がやりました)、予測可能なエラーが起きてコード生成のステップが失敗に終わります。
この例では、JavaソースファイルやHibernateマッピングファイルのカスタム化は一切しませんでした。すべてはPowerDesignerのデフォルト機能を使って生成されました。しかしPowerDesignerには、エンティティタイプの階層におけるディスクリミネータ値の使用など、Hibernateマッピングの高度なサポートが含まれています。
次の例は、PowerDesigner 15.2によってEmployeesテーブル用に生成されたHibernateマッピングファイル「Employees.hbm.xml」です。
<?xml version="1.0" encoding="UTF-8"?>
<!-- Hibernate XML Mapping File -->
<!-- Author: paulley -->
<!-- Modified:Monday, June 28, 2010 1:49:22 PM -->
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="true" default-cascade="none" default-access="property">
<class name="Employees" mutable="true" dynamic-update="false" dynamic-insert="false" select-before-update="false" lazy="true" abstract="false">
<id name="employeeID">
<column name="EmployeeID" sql-type="int" not-null="true"/>
</id>
<property name="managerID" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="ManagerID" sql-type="int"/>
</property>
<property name="surname" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="Surname" sql-type="char(20)" not-null="true" length="20"/>
</property>
<property name="givenName" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="GivenName" sql-type="char(20)" not-null="true" length="20"/>
</property>
<property name="street" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="Street" sql-type="char(30)" not-null="true" length="30"/>
</property>
<property name="city" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="City" sql-type="char(20)" not-null="true" length="20"/>
</property>
<property name="state" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="State" sql-type="char(16)" length="16"/>
</property>
<property name="country" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="Country" sql-type="char(16)" length="16"/>
</property>
<property name="postalCode" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="PostalCode" sql-type="char(10)" length="10"/>
</property>
<property name="phone" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="Phone" sql-type="char(13)" length="13"/>
</property>
<property name="status" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="Status" sql-type="char(2)" length="2"/>
</property>
<property name="socialSecurityNumber" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="SocialSecurityNumber" sql-type="char(11)" length="11"/>
</property>
<property name="salary" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="Salary" sql-type="numeric(20,3)" not-null="true" length="20" precision="3"/>
</property>
<property name="startDate" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="StartDate" sql-type="date" not-null="true"/>
</property>
<property name="terminationDate" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="TerminationDate" sql-type="date"/>
</property>
<property name="birthDate" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="BirthDate" sql-type="date"/>
</property>
<property name="benefitHealthInsurance" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="BenefitHealthInsurance" sql-type="bit"/>
</property>
<property name="benefitLifeInsurance" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="BenefitLifeInsurance" sql-type="bit"/>
</property>
<property name="benefitDayCare" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="BenefitDayCare" sql-type="bit"/>
</property>
<property name="sex" insert="true" update="true" lazy="false" optimistic-lock="true">
<column name="Sex" sql-type="char(2)" length="2"/>
</property>
<many-to-one name="departments" class="Departments" outer-join="false" update="true" insert="true">
<column name="DepartmentID" sql-type="int" not-null="true" length="0"/>
</many-to-one>
<bag name="departments" outer-join="false" lazy="true" optimistic-lock="true">
<key on-delete="noaction" unique="false">
<column name="DepartmentHeadID" sql-type="int" not-null="false" length="0"/>
</key>
<one-to-many class="Departments"/>
</bag>
<bag name="salesOrders" outer-join="false" lazy="true" optimistic-lock="true">
<key on-delete="noaction" unique="false">
<column name="SalesRepresentative" sql-type="int" not-null="true" length="0"/>
</key>
<one-to-many class="SalesOrders"/>
</bag>
</class>
</hibernate-mapping>
そしてこれに対応する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();
}
}



