Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement hashcode etc for @Entities #22

Open
debuglevel opened this issue Nov 15, 2021 · 0 comments
Open

Implement hashcode etc for @Entities #22

debuglevel opened this issue Nov 15, 2021 · 0 comments

Comments

@debuglevel
Copy link
Owner

debuglevel commented Nov 15, 2021

Will break you neck sooner or later.
e.g. because toSet() creates a hashset which has to get the hash, which will recurse into the (lazy loaded) collections of the Entity - and breaks with some exception:

Unexpected error occurred: failed to lazily initialize a collection of role: de.debuglevel.walkingdinner.backend.organisation.Organisation.dinners, could not initialize proxy - no Session
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.debuglevel.walkingdinner.backend.organisation.Organisation.dinners, could not initialize proxy - no Session
...
	at org.hibernate.collection.internal.PersistentSet.hashCode(PersistentSet.java:458)
	at de.debuglevel.walkingdinner.backend.organisation.Organisation.hashCode(Organisation.kt)
	at java.util.HashMap.hash(HashMap.java:339)
	at java.util.HashMap.put(HashMap.java:612)
	at java.util.HashSet.add(HashSet.java:220)
	at kotlin.collections.CollectionsKt___CollectionsKt.toCollection(_Collections.kt:1294)
	at kotlin.collections.CollectionsKt___CollectionsKt.toSet(_Collections.kt:1346)
	at de.debuglevel.walkingdinner.backend.organisation.OrganisationService.getAll(OrganisationService.kt:22)

Also add something to DEVELOPMENT.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant