Update: the hbm2pascal web page at
http://hbm2pascal.appspot.com/ now also includes example mapping files for two database systems:
HSQLDBwith three database tables
Firebird with ten database tables:
* Country.hbm.xml
* Customer.hbm.xml
* Department.hbm.xml
* Employee.hbm.xml
* Job.hbm.xml
* PhoneList.hbm.xml
* ProjDeptBudget.hbm.xml
* Project.hbm.xml
* SalaryHistory.hbm.xml
* Sales.hbm.xml
The conversion creates 15 source files (including interface and composite key class units).
Example: Country.pas, generated code
unit Country;
interface
uses
// Interface declarations
AllInterfaces,
// required units
SysUtils, Classes;
type
(**
* Country class.
*)
TCountry = class (TInterfacedObject, ICountry)
private
FCountry: string;
FCurrency: string;
FCustomers: TInterfaceList;
FJobs: TInterfaceList;
// getter methods
function GetCountry: string;
function GetCurrency: string;
function GetCustomers: TInterfaceList;
function GetJobs: TInterfaceList;
// setter methods
procedure SetCountry(const Value: string);
procedure SetCurrency(const Value: string);
public
constructor Create;
destructor Destroy; override;
// properties
property Country: string read GetCountry write SetCountry;
property Currency: string read GetCurrency write SetCurrency;
property Customers: TInterfaceList read GetCustomers;
property Jobs: TInterfaceList read GetJobs;
end;
implementation
{ TCountry }
constructor TCountry.Create;
begin
inherited;
FCustomers := TInterfaceList.Create;
FJobs := TInterfaceList.Create;
end;
destructor TCountry.Destroy;
begin
FCustomers.Free;
FJobs.Free;
inherited;
end;
function TCountry.GetCountry: string;
begin
Result := FCountry;
end;
function TCountry.GetCurrency: string;
begin
Result := FCurrency;
end;
function TCountry.GetCustomers: TInterfaceList;
begin
Result := FCustomers;
end;
function TCountry.GetJobs: TInterfaceList;
begin
Result := FJobs;
end;
procedure TCountry.SetCountry(const Value: string);
begin
FCountry := Value;
end;
procedure TCountry.SetCurrency(const Value: string);
begin
FCurrency := Value;
end;
end.
hbm2pascal is under development. If you find it useful or have feature suggestions, your feedback is very appreciated.
Best regards
--
Michael Justin
http://www.mikejustin.com/ (see page footer for contact information)