As I've found myself repeating myself a lot, writing very similar queries and classes for different entities (despite of doing strong object and relational normalisation), etc, I've came to an Idea that I could and should automate the most of this and write an engine which will compile simple declarative models I specify into all the code limiting my job to describe the task and and finally just customise the result as needed.
As far as I know this is about metaprogramming and aspect-oriented programming. How do I get acquainted with modern tools available quickly so that I don't invent one more bicycle developing my own?