text
stringlengths
0
234
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation
Function Body: (Wiki_Page_Impl, Wiki_Page_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Wiki_Page_Impl_Ptr := Wiki_Page_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Wiki_Page_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, WIKI_PAGE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Wiki_Page_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Wiki_Page_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (WIKI_PAGE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- last_version
Value => Object.Last_Version);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_2_NAME, -- is_public
Value => Object.Is_Public);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- title
Value => Object.Title);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_2_NAME, -- read_count
Value => Object.Read_Count);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_2_NAME, -- preview_id
Value => Object.Preview);
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_2_NAME, -- wiki_id
Value => Object.Wiki);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_2_NAME, -- content_id
Value => Object.Content);
Object.Clear_Modified (10);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",