I actually wanted to use one library that I once saw, but I completely forgot how it's called :( After half an hour of googling I just gave up. This library is specifically designed to give nice DSL for creating links for the HATEOAS-style services. 

I think the main concern I had here is that persistence classes contained link-creation logic. They were aware of link structure, server host, port, etc. IMHO it belongs to the upper levels.