Closed redfoxanna closed 4 months ago
Hi @redfoxanna!
This is an interesting one! Here are some things I noticed/wonder:
Hi @pawaitemadisoncollege!
Looking at Google and some of the errors I'm seeing from the screenshots, it might have something to do with tables being lazy loading of associated entities. I am wondering if the collections in my entities need to have a fetchType=EAGER?
Could this be a time zone issue? I thought I fixed that but now am remembering that you said we might have to run those commands every so often unless we go into the config file for mysql and change the time setting. I will try that and see if that does anything!
Yes! Eager is likely the key here! Let me know if that does it!
Hi @pawaitemadisoncollege, I have passing unit tests! I went back to a version of my code from many week ago where I knew the tests were all passing. From there I had to add:
@OneToMany(mappedBy = "poem", fetch = FetchType.EAGER, cascade = CascadeType.REMOVE)
private Set<PoemGenre> genres = new HashSet<>();
I also updated .equals()
and .hashcode()
to include the collections and now the tests have ran a few times with no issues!
Thanks for your help! :-)
Awesome!!! I think I mentioned "eager" in week 5, but obviously need to emphasize that more!!! Glad you got it working!
Hi @pawaitemadisoncollege, I reconfigured Diamond Poems so that I have a many-to-many relationship between Poem and Genre. I followed the videos you have for hibernate many-to-many relationships and created a new PoemGenre entity to represent that relationship-- similar to your OrderProduct example in the video.
My issue is now that I go back and run my unit tests, they are failing. I am getting null for database.connection seen here. For the life of me I can't debug this. I've checked that the properties for the database were being loaded correctly (they are), I have checked over my hibernate.cfg.xml and am now out of ideas.
The strange part is, the insertSuccess() test is working just fine?
Is there something I missed when mapping out the relationship between Poem, Genre and PoemGenre? Or is this more likely a configuration issue?