3 ms·
I might start to get what you are hinting at. Still the > JPA is conceptually incapable of automatically utilising the structure of the underlying database (de
by eitland 6y ago
I might start to get what you are hinting at. Still the
> JPA is conceptually incapable of automatically utilising the structure of the underlying database (despite the fact that the database structure is actually dynamic), so it makes up for it by requiring you to write these huge entity models which declare - and duplicate - that structure. You effectively “throw away” the database structure because you have to rewrite it in Java/JPA.
The way you wrote it: "you get to throw away" made it seem like you have to throw away your knowledge. (emphasis mine)
What you describe above is easy to read, but is of course not "throwing away" but duplication, which is of course an issue, but a totally different one.
> I mentioned indexes but that’s just a side issue.
Is indexes an issue with JPA or not? ;-)
You (or others) might wonder why I pick at your comment but I am so tired of seing people choosing inferior solutions because people are scaring them away from what would be perfect solutions for them.
- doctor_eval 6y agoIt’s fine to pick at my comments, that’s what HN is for! I accept that when I said “you get to throw away...” I was being a bit glib. I meant that we write the DDL, run it, and despite it being stored in the database as structure, that DDL is never used again by JPA and you have to rewrite it in annotations. I thought lack of knowledge about indexes was an issue because I had a use case where the generated SQL was (very) sub optimal and thought it was due to an assumption made by JPA, but someone pointed out that maybe I used a Set instead of a List. I still think that’s stupid (it’s hardly fixing the “impedance mismatch” when which is the very purpose of JPA), but might not be index related. That said, knowledge about indexes does impact the design of handwritten queries and JPA doesn’t have that; JPA queries can be overly complex, and even pathological, so again I think the point holds up. In my defence I was listing a lot of issues. I feel like I could write a book on the problems with JPA but all I had was this tiny box on my phone. In terms of scaring people off, that is definitely my intent. There are lots of great ways to get Java talking to SQL, many linked to in this thread, and IMO the majority of developers would be better off choosing almost any alternative over JPA.
- eitland 6y agoI still think your experience is a bit on the extreme side but I'll still admit you've got me thinking: not because I've seen ORM causing much problems (I can use them just fine with indexes and custom SQL) but because maybe there is a better way. Last I read up on MyBatis is probably >10 years ago and IIRC at that point it seemed like a manifestation of what the Rails guys teased us with: <situps> <up/> <down/> </situps> but I'll admit: - I've been wrong before - things might have changed in 10 years - I've always known there were cases for something else but maybe I should adjust my threshold For anyone else who reads this, just be aware that many smart people are happily using JPA. :-)