is jpa a good alternative for persistence for a ko...
# announcements
c
is jpa a good alternative for persistence for a kotlin app? I have been using only nosql databases for years and for my next project i think i should use a relational db.
n
jpa is the “standard” for java ee which can be an arguments for or against depending on which side of the fence you sit if you’re a spring user check the spring data jpa project which makes things really really easy
c
i havent used spring for 10+ years or so, but why not try that again
n
the real nice thing is you can define only abstract methods on interfaces and the name of method will send the right request e.g.
Person PersonRepository<Long,Person>.findByFirstName(String name)
will do a
SELECT * FROM PERSON WHERE FIRST_NAME={name}
c
is that specific to spring or is that jpa?
e
check out jdbi
n
that is spring data jpa it just requires a jpa model
c
hmm jdbi also looks nice!
u
Here’s a short list of db frameworks: https://www.kotlinresources.com/tag/database/
f
I have started using jooq and that has been just awesome. Depends on how much control you want over your queries
But it feels real nice to be able to write actual sql and know what is happening instead of navigating around some jpa abstraction
c
is that similar to exposed?
n
Repository interface provided by Spring Data is great and I would recommend it for speedy development. JPA is generally a good idea in the sense that you're putting your trust in a language standard and Java standards tend to live like forever. Kotlin does add hint of mint over this.
n
But it feels real nice to be able to write actual sql
it always surprises me to read such statements the history of software development has always moved toward higher abstractions not lower otherwise, we still would write our programs in 0 and 1
i’m not a fervent partisan of jpa but with spring data jpa it feels really great 95% of the time and when not, well, you can always write your native queries
f
@nfrankel that is not really an argument to avoid sql all together. You can write code of much higher abstraction in sql than you can in kotlin for certain sceonarios, the difference is mainly that sql is made to deal with relational databases and kotlin/java has a whole other way of looking at it. Sure, it can be nice to get rid of basic CRUD stuff with a library, I used that myself but jooq is really the sweet spot for me when it comes to control. If I know how to get what I want om sql, I should be able to write that in a nice way i.e not passing a plain string