|
Antwort |
Registriert seit: 14. Apr 2008
Vor einigen Jahren habe ich eine kleine Webanwendung geschrieben, die als Eingabe eine Hibernate Mapping (HBM) Datei mit einer Datenbank-Tabellenbeschreibung erhält. Als Ausgabe erstellt sie Delphi Units mit denen die Tabellen und ihre Beziehungen objektorientiert dargestellt werden.
Die hbm2pascal Anwendung läuft unter http://hbm2pascal.appspot.com/ Beim ersten Start der Anwendung kann es einige Sekunden dauern, bis die Festplatten der Google App Engine auf Betriebsgeschwindigkeit laufen Eventuell ist eine Anpassung der Anwendung auf neuere ORM Systeme wie DORM oder Aurelius möglich, bei Interesse freue ich mich über Feedback. Beispiel Sourcecode, generiert für die Firebird Demodatenbank EMPLOYEE (Generator im Internet unter http://hbm2pascal.appspot.com/firebird.jsp):
Delphi-Quellcode:
(**
* Generated May 2, 2013 8:33:06 AM by hbm2pascal * (c) Michael Justin - http://www.mikejustin.com/ *) unit AllInterfaces; interface uses // import declarations of component interfaces JobId, ProjDeptBudgetId, SalaryHistoryId, PhoneListId, SysUtils; type // forward declarations IJob = interface; ICustomer = interface; ISales = interface; IProjDeptBudget = interface; ISalaryHistory = interface; IProject = interface; IDepartment = interface; ICountry = interface; IPhoneList = interface; IEmployee = interface; // business object interfaces (** * IJob interface. *) IJob = interface // getter methods function GetId: IJobId; function GetCountry: ICountry; function GetJobTitle: string; function GetMinSalary: Currency; function GetMaxSalary: Currency; function GetJobRequirement: string; function GetLanguageReq: string; function GetEmployees: TInterfaceList; // setter methods procedure SetId(const Value: IJobId); procedure SetCountry(const Value: ICountry); procedure SetJobTitle(const Value: string); procedure SetMinSalary(const Value: Currency); procedure SetMaxSalary(const Value: Currency); procedure SetJobRequirement(const Value: string); procedure SetLanguageReq(const Value: string); // properties property Id: IJobId read GetId write SetId; property Country: ICountry read GetCountry write SetCountry; property JobTitle: string read GetJobTitle write SetJobTitle; property MinSalary: Currency read GetMinSalary write SetMinSalary; property MaxSalary: Currency read GetMaxSalary write SetMaxSalary; property JobRequirement: string read GetJobRequirement write SetJobRequirement; property LanguageReq: string read GetLanguageReq write SetLanguageReq; property Employees: TInterfaceList read GetEmployees; end; (** * ICustomer interface. *) ICustomer = interface // getter methods function GetCustNo: Integer; function GetCountry: ICountry; function GetCustomer: string; function GetContactFirst: string; function GetContactLast: string; function GetPhoneNo: string; function GetAddressLine1: string; function GetAddressLine2: string; function GetCity: string; function GetStateProvince: string; function GetPostalCode: string; function GetOnHold: Char; function GetSaleses: TInterfaceList; // setter methods procedure SetCustNo(const Value: Integer); procedure SetCountry(const Value: ICountry); procedure SetCustomer(const Value: string); procedure SetContactFirst(const Value: string); procedure SetContactLast(const Value: string); procedure SetPhoneNo(const Value: string); procedure SetAddressLine1(const Value: string); procedure SetAddressLine2(const Value: string); procedure SetCity(const Value: string); procedure SetStateProvince(const Value: string); procedure SetPostalCode(const Value: string); procedure SetOnHold(const Value: Char); // properties property CustNo: Integer read GetCustNo write SetCustNo; property Country: ICountry read GetCountry write SetCountry; property Customer: string read GetCustomer write SetCustomer; property ContactFirst: string read GetContactFirst write SetContactFirst; property ContactLast: string read GetContactLast write SetContactLast; property PhoneNo: string read GetPhoneNo write SetPhoneNo; property AddressLine1: string read GetAddressLine1 write SetAddressLine1; property AddressLine2: string read GetAddressLine2 write SetAddressLine2; property City: string read GetCity write SetCity; property StateProvince: string read GetStateProvince write SetStateProvince; property PostalCode: string read GetPostalCode write SetPostalCode; property OnHold: Char read GetOnHold write SetOnHold; property Saleses: TInterfaceList read GetSaleses; end; (** * ISales interface. *) ISales = interface // getter methods function GetPoNumber: string; function GetEmployee: IEmployee; function GetCustomer: ICustomer; function GetOrderStatus: string; function GetOrderDate: TDateTime; function GetShipDate: TDateTime; function GetDateNeeded: TDateTime; function GetPaid: Char; function GetQtyOrdered: Integer; function GetTotalValue: Currency; function GetDiscount: Extended; function GetItemType: string; function GetAged: Currency; // setter methods procedure SetPoNumber(const Value: string); procedure SetEmployee(const Value: IEmployee); procedure SetCustomer(const Value: ICustomer); procedure SetOrderStatus(const Value: string); procedure SetOrderDate(const Value: TDateTime); procedure SetShipDate(const Value: TDateTime); procedure SetDateNeeded(const Value: TDateTime); procedure SetPaid(const Value: Char); procedure SetQtyOrdered(const Value: Integer); procedure SetTotalValue(const Value: Currency); procedure SetDiscount(const Value: Extended); procedure SetItemType(const Value: string); procedure SetAged(const Value: Currency); // properties property PoNumber: string read GetPoNumber write SetPoNumber; property Employee: IEmployee read GetEmployee write SetEmployee; property Customer: ICustomer read GetCustomer write SetCustomer; property OrderStatus: string read GetOrderStatus write SetOrderStatus; property OrderDate: TDateTime read GetOrderDate write SetOrderDate; property ShipDate: TDateTime read GetShipDate write SetShipDate; property DateNeeded: TDateTime read GetDateNeeded write SetDateNeeded; property Paid: Char read GetPaid write SetPaid; property QtyOrdered: Integer read GetQtyOrdered write SetQtyOrdered; property TotalValue: Currency read GetTotalValue write SetTotalValue; property Discount: Extended read GetDiscount write SetDiscount; property ItemType: string read GetItemType write SetItemType; property Aged: Currency read GetAged write SetAged; end; (** * IProjDeptBudget interface. *) IProjDeptBudget = interface // getter methods function GetId: IProjDeptBudgetId; function GetProject: IProject; function GetDepartment: IDepartment; function GetQuartHeadCnt: Integer; function GetProjectedBudget: Currency; // setter methods procedure SetId(const Value: IProjDeptBudgetId); procedure SetProject(const Value: IProject); procedure SetDepartment(const Value: IDepartment); procedure SetQuartHeadCnt(const Value: Integer); procedure SetProjectedBudget(const Value: Currency); // properties property Id: IProjDeptBudgetId read GetId write SetId; property Project: IProject read GetProject write SetProject; property Department: IDepartment read GetDepartment write SetDepartment; property QuartHeadCnt: Integer read GetQuartHeadCnt write SetQuartHeadCnt; property ProjectedBudget: Currency read GetProjectedBudget write SetProjectedBudget; end; (** * ISalaryHistory interface. *) ISalaryHistory = interface // getter methods function GetId: ISalaryHistoryId; function GetEmployee: IEmployee; function GetOldSalary: Currency; function GetPercentChange: Extended; function GetNewSalary: Extended; // setter methods procedure SetId(const Value: ISalaryHistoryId); procedure SetEmployee(const Value: IEmployee); procedure SetOldSalary(const Value: Currency); procedure SetPercentChange(const Value: Extended); procedure SetNewSalary(const Value: Extended); // properties property Id: ISalaryHistoryId read GetId write SetId; property Employee: IEmployee read GetEmployee write SetEmployee; property OldSalary: Currency read GetOldSalary write SetOldSalary; property PercentChange: Extended read GetPercentChange write SetPercentChange; property NewSalary: Extended read GetNewSalary write SetNewSalary; end; (** * IProject interface. *) IProject = interface // getter methods function GetProjId: string; function GetEmployee: IEmployee; function GetProjName: string; function GetProjDesc: string; function GetProduct: string; function GetEmployees: TInterfaceList; function GetProjDeptBudgets: TInterfaceList; // setter methods procedure SetProjId(const Value: string); procedure SetEmployee(const Value: IEmployee); procedure SetProjName(const Value: string); procedure SetProjDesc(const Value: string); procedure SetProduct(const Value: string); // properties property ProjId: string read GetProjId write SetProjId; property Employee: IEmployee read GetEmployee write SetEmployee; property ProjName: string read GetProjName write SetProjName; property ProjDesc: string read GetProjDesc write SetProjDesc; property Product: string read GetProduct write SetProduct; property Employees: TInterfaceList read GetEmployees; property ProjDeptBudgets: TInterfaceList read GetProjDeptBudgets; end; (** * IDepartment interface. *) IDepartment = interface // getter methods function GetDeptNo: string; function GetEmployee: IEmployee; function GetDepartment: IDepartment; function GetDepartment_1: string; function GetBudget: Currency; function GetLocation: string; function GetPhoneNo: string; function GetDepartments: TInterfaceList; function GetProjDeptBudgets: TInterfaceList; function GetEmployees: TInterfaceList; // setter methods procedure SetDeptNo(const Value: string); procedure SetEmployee(const Value: IEmployee); procedure SetDepartment(const Value: IDepartment); procedure SetDepartment_1(const Value: string); procedure SetBudget(const Value: Currency); procedure SetLocation(const Value: string); procedure SetPhoneNo(const Value: string); // properties property DeptNo: string read GetDeptNo write SetDeptNo; property Employee: IEmployee read GetEmployee write SetEmployee; property Department: IDepartment read GetDepartment write SetDepartment; property Department_1: string read GetDepartment_1 write SetDepartment_1; property Budget: Currency read GetBudget write SetBudget; property Location: string read GetLocation write SetLocation; property PhoneNo: string read GetPhoneNo write SetPhoneNo; property Departments: TInterfaceList read GetDepartments; property ProjDeptBudgets: TInterfaceList read GetProjDeptBudgets; property Employees: TInterfaceList read GetEmployees; end; (** * ICountry interface. *) ICountry = interface // 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); // 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; (** * IPhoneList interface. *) IPhoneList = interface // getter methods function GetId: IPhoneListId; // setter methods procedure SetId(const Value: IPhoneListId); // properties property Id: IPhoneListId read GetId write SetId; end; (** * IEmployee interface. *) IEmployee = interface // getter methods function GetEmpNo: SmallInt; function GetJob: IJob; function GetDepartment: IDepartment; function GetFirstName: string; function GetLastName: string; function GetPhoneExt: string; function GetHireDate: TDateTime; function GetSalary: Currency; function GetFullName: string; function GetSalaryHistories: TInterfaceList; function GetProjects: TInterfaceList; function GetDepartments: TInterfaceList; function GetProjects_1: TInterfaceList; function GetSaleses: TInterfaceList; // setter methods procedure SetEmpNo(const Value: SmallInt); procedure SetJob(const Value: IJob); procedure SetDepartment(const Value: IDepartment); procedure SetFirstName(const Value: string); procedure SetLastName(const Value: string); procedure SetPhoneExt(const Value: string); procedure SetHireDate(const Value: TDateTime); procedure SetSalary(const Value: Currency); procedure SetFullName(const Value: string); // properties property EmpNo: SmallInt read GetEmpNo write SetEmpNo; property Job: IJob read GetJob write SetJob; property Department: IDepartment read GetDepartment write SetDepartment; property FirstName: string read GetFirstName write SetFirstName; property LastName: string read GetLastName write SetLastName; property PhoneExt: string read GetPhoneExt write SetPhoneExt; property HireDate: TDateTime read GetHireDate write SetHireDate; property Salary: Currency read GetSalary write SetSalary; property FullName: string read GetFullName write SetFullName; property SalaryHistories: TInterfaceList read GetSalaryHistories; property Projects: TInterfaceList read GetProjects; property Departments: TInterfaceList read GetDepartments; property Projects_1: TInterfaceList read GetProjects_1; property Saleses: TInterfaceList read GetSaleses; end; implementation end.
Delphi-Quellcode:
(**
* Generated May 2, 2013 8:33:11 AM by hbm2pascal * (c) Michael Justin - http://www.mikejustin.com/ *) 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. |
Ansicht |
Linear-Darstellung |
Zur Hybrid-Darstellung wechseln |
Zur Baum-Darstellung wechseln |
ForumregelnEs ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus. Trackbacks are an
Pingbacks are an
Refbacks are aus
|
|
Nützliche Links |
Heutige Beiträge |
Sitemap |
Suchen |
Code-Library |
Wer ist online |
Alle Foren als gelesen markieren |
Gehe zu... |
LinkBack |
LinkBack URL |
About LinkBacks |