Closed kileader closed 3 years ago
I decided to design the user table like in the videos, but I am planning on making wishlists and ranking settings as well. I suppose I can have the user ID as a foreign key into those tables and be able to have them as a one to many.
Regarding DB design - yes, it makes sense that the userid will be a foreign key in some of your other tables. The topic for week 5 is one-to-many relationships with hibernate, so choosing one of those for the week 5 exercise should work well.
I have been typing your code manually rather than copy-paste, because I didn't figure out where to find it.
The user display demo code is here: https://github.com/mad-java-ent-s21/user-display-demo-code. I have a branch for each demo or mini-topic. If you can't access that for some reason, let me know. There are also snippets of code on the course website. If you are looking for something and can't find it, please ask (not that there's any harm in typing out the code).
And I don't have anything in the code coverage. I guess it isn't looking for coverage in the right place? I don't know how to fix it.
Your screenshots show the code coverage for the userdao that I was expecting. Maybe you resolved this since creating this issue?
And I don't understand the convention for using logger.info versus logger.debug and what messages I should be writing for them.
The various logging levels are used to control what will be written to the log file. The logging level can be controlled in log4j2.properties. If a level of warn is set there, then even if all of these log statements exist in your code, only the warn, error, and fatal messages will actually be written out: log.trace("Trace Message!"); log.debug("Debug Message!"); log.info("Info Message!"); log.warn("Warn Message!"); log.error("Error Message!"); log.fatal("Fatal Message!");
The gives the developer the ability to turn up or turn down logging, based on what they want to see. In a local or dev environment, I may want to see all messages, such as trace, debug, info, etc. But in production, perhaps I only want to log out warnings and above (we might need to be careful in a production environment that we not log out personal health or credit information, for example). If I am troubleshooting a problem I might turn logging "up" to produce more log level messages, whereas under normal conditions I don't want all those log messages clogging up the logs and only care about errors. Does that help? https://www.tutorialspoint.com/log4j/log4j_logging_levels.htm
Ah! I saw your edit at the bottom - glad you got those figured out. I should have read through everything before responding!
assertTrue(expectedUser.equals(actualUser));
so that you don't have to compare each instance var/column manually like this: https://github.com/kileader/Budget-Game-Rankings/blob/6be4a7c36c20db8a967bb62ae4547337d7719c61/src/test/java/com/kevinleader/bgr/persistence/UserDaoTest.java#L40-L42@pawaitemadisoncollege Thanks for answering so thoroughly! I bookmarked the demo code.
I'll try being liberal with log.debug (every method), use log.info at a higher level (at start of a sequence of methods), and use the others as warning or fail cases.
I'll keep in mind ways to be more efficient with comparing entities.
@pawaitemadisoncollege week 4 is complete
My key learning point was alot of hibernate. I don't quite understand what's going on, but it seems good at what it does after everything is set correctly.
A challenge was figuring out how to integrate Hibernate and the database itself into my project. I decided to design the user table like in the videos, but I am planning on making wishlists and ranking settings as well. I suppose I can have the user ID as a foreign key into those tables and be able to have them as a one to many.
I had a few problems with MySQL, and I messed up my password with trying to change it via different instructions that I googled, so I redownloaded it. I'm at least not getting the weird bug anymore that makes me unable to use the L key for anything but bringing up MySQL Command Line Client while it's on for the first time.
I don't understand the errors I'm getting when running the tests, despite them all passing. And I don't have anything in the code coverage. I guess it isn't looking for coverage in the right place? I don't know how to fix it.
Also, I tried implementing more logging for hibernate, but I think something in the log4j2.properties is incorrect. I have been typing your code manually rather than copy-paste, because I didn't figure out where to find it. And I don't understand the convention for using logger.info versus logger.debug and what messages I should be writing for them.
EDIT: I fixed the code coverage and logging problem. Added the screenshots. I still don't know how exactly I should be logging though.