I once described Java as being my happy place when it comes to programming.  There are a lot of good reason why.  Strong typing / speed / portability etc etc.  However since returning to the Java world from PHP, I have totally embraced Spring Boot and everything it stands for.

Most recently, for this site, I have been playing with Mongo and JPA.  Frankly I know hardly anything of Mongo which is a true testament to JPA and Spring Crud Repositories.  You very soon forget about the database you are using and just write code.

For my latest release, I wanted to Sort the acticles by date desc and limit them to about 10.  Normally you would go hacking some SQL limit and sort stuff, but In the JPA all I had to do was modify my find all method.  So lets say I had something like this to start..


to add the order by and limit I just changed the method signature to

repository.findAllOrderByCreationDateDesc( new PageRequest(0, 10));

No SQL needed :D​