Spring Data: bi-directional relationships

Should we map both sides? https://stackoverflow.com/questions/30464782/how-to-maintain-bi-directional-relationships-with-spring-data-rest-and-jpa/30474303#30474303 It usually simplifies the matter if you try not to use bi-directional relationship whenever possible and rather fall back to a repository to obtain all the entities that make up the backside of the association. https://thorben-janssen.com/best-practices-many-one-one-many-associations-mappings/ https://twitter.com/odrotbohm/status/603247455094841344 https://stackoverflow.com/questions/48754783/do-i-have-to-set-both-sides-for-a-bidirectional-relationship If Yes - Do we have to manually update both sides? https://stackoverflow.com/questions/7546161/update-bidirectional-manytomany-from-both-sides https://stackoverflow.com/questions/20068742/jpa-updating-bidirectional-association https://hellokoding.com/jpa-one-to-many-relationship-mapping-example-with-spring-boot-maven-and-mysql/ CascadeType.ALL is for propagating the CRUD operations on the parent entity to the child entities....

August 10, 2022 · 133 words · Peter Dieleman

Persisting ArrayList

https://stackoverflow.com/questions/25415738/how-to-persist-arraylist-within-spring-entity-class Need: @ElementCollection & @CollectionTable(name="abc") ? https://thorben-janssen.com/hibernate-tips-elementcollection/ Does this still require a separate table? https://stackoverflow.com/questions/26512916/what-column-type-is-required-when-using-elementcollection-with-jpa https://www.postgresql.org/docs/current/arrays.html https://sajithv.medium.com/spring-jpa-data-with-postgres-array-types-a6cc4be421e2 Hibernate & Arrays From: Vlad Mihalcea " Hibernate ORM does not support ARRAY column types" Also see: https://stackoverflow.com/questions/1647583/how-to-map-a-postgresql-array-with-hibernate Semi-canonical solution Use: https://github.com/vladmihalcea/hibernate-types https://vladmihalcea.com/how-to-map-java-and-sql-arrays-with-jpa-and-hibernate/ PostgreSQL data types https://www.postgresql.org/docs/current/arrays.html And there’s this https://stackoverflow.com/questions/69858533/replacement-for-hibernates-deprecated-type-annotation https://stackoverflow.com/questions/4332467/mapping-array-with-hibernate https://stackoverflow.com/questions/62647125/hibernate-envers-does-not-recognize-custom-types-from-hibernate-types-52

August 3, 2022 · 50 words · Peter Dieleman