Stored procedures are the way to store programs in the database.
Simple stored procedure (oracle) to print out a string via DBMS_OUTPUT:
CREATE OR REPLACE PROCEDURE STHELLOSTORED
IS BEGIN
DBMS_OUTPUT.PUT_LINE('Hello Oracle Stored');
END;
Declare the call to stored in XML file:
<statements>
<update id="helloStored">
begin
STHELLOSTORED;
END;
</update>
</statements>
Java code to call the stored STHELLOSTORED:
Queryable q = QueryFactory.of("helloStored");
repository.update(q);