This talk is hilarious: https://vimeo.com/28885655 and helped to soothe my anger a lot while fighting with Hibernate's
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.example.vok.Article.comments, could not initialize proxy - no Session
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:582)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:201)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:561)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:132)
at org.hibernate.collection.internal.PersistentBag.iterator(PersistentBag.java:277)
at kotlin.collections.CollectionsKt___CollectionsKt.joinTo(_Collections.kt:2013)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString(_Collections.kt:2031)
at kotlin.collections.CollectionsKt___CollectionsKt.joinToString$default(_Collections.kt:2030)
at com.example.vok.ArticleView$refreshComments$1.invoke(ArticleView.kt:71)
at com.example.vok.ArticleView$refreshComments$1.invoke(ArticleView.kt:16)
at com.github.vok.framework.DBKt.db(DB.kt:146)
As it turns out, I had a detached article and there is no way of reattaching it back to the session! How dumb is that? https://stackoverflow.com/questions/912659/what-is-the-proper-way-to-re-attach-detached-objects-in-hibernate/4438358#4438358
So instead of article.comments.forEach {...} you need to write Article.find(article.id!!)!!.comments.forEach {...} to force Hibernate to reload the entity and make the bloody comments collection attached. Smooth 👎
So there goes Hibernate. I kinda liked Ebean until I realized it needs to do some compile-time class enhancement with Maven Tiles - 👎 , sorry, no, I'm not going to install a plugin into my IDE just to develop with Ebean. There goes Ebean.
I remember EclipseLink having troubles with sequences as primary keys generators: I believe EclipseLink started with 51 instead of 1, and then EclipseLink wondered where the hell is record number 1: http://stackoverflow.com/questions/18474046/eclipselink-and-sequence-generator-preallocation 👎
Anyway, it seems that JPA is hated by the interwebs with glaring passion: https://virgo47.wordpress.com/2014/10/09/jpa-is-it-worth-it-horror-stories-with-eclipselink-and-hibernate/
and https://www.reddit.com/r/java/comments/ln2st/jpa_the_mother_of_all_leaky_abstractions/
JPA - the mother of all leaky abstractions :-D Kinda says it all. There's no way I'm going to touch Spring Data (because it has Spring in it 👎 ), which leaves us either with (yet) another JDBC wrapper library, or https://github.com/JetBrains/Exposed . It looks quite foreign to me, but I'll evaluate.
More blogs from people pissed by Hibernate:
This talk is hilarious: https://vimeo.com/28885655 and helped to soothe my anger a lot while fighting with Hibernate's
As it turns out, I had a detached
articleand there is no way of reattaching it back to the session! How dumb is that? https://stackoverflow.com/questions/912659/what-is-the-proper-way-to-re-attach-detached-objects-in-hibernate/4438358#4438358So instead of
article.comments.forEach {...}you need to writeArticle.find(article.id!!)!!.comments.forEach {...}to force Hibernate to reload the entity and make the bloodycommentscollection attached. Smooth 👎So there goes Hibernate. I kinda liked Ebean until I realized it needs to do some compile-time class enhancement with Maven Tiles - 👎 , sorry, no, I'm not going to install a plugin into my IDE just to develop with Ebean. There goes Ebean.
I remember EclipseLink having troubles with sequences as primary keys generators: I believe EclipseLink started with 51 instead of 1, and then EclipseLink wondered where the hell is record number 1: http://stackoverflow.com/questions/18474046/eclipselink-and-sequence-generator-preallocation 👎
Anyway, it seems that JPA is hated by the interwebs with glaring passion: https://virgo47.wordpress.com/2014/10/09/jpa-is-it-worth-it-horror-stories-with-eclipselink-and-hibernate/
and https://www.reddit.com/r/java/comments/ln2st/jpa_the_mother_of_all_leaky_abstractions/
JPA - the mother of all leaky abstractions :-D Kinda says it all. There's no way I'm going to touch Spring Data (because it has Spring in it 👎 ), which leaves us either with (yet) another JDBC wrapper library, or https://github.com/JetBrains/Exposed . It looks quite foreign to me, but I'll evaluate.
More blogs from people pissed by Hibernate: