I got probably a good 3-5 hours in this weekend concentrating on working through another Hibernate tutorial, experimenting with the tutorials further, and looking through the documentation. I feel I already have a better understanding of the way things work than I did the last time around. This lazy loading stuff is pretty wild the way it works. For instance, say you’ve got a class that has a collection of objects that is stored in another table. Until you actually attempt to access, it hasn’t actually done a database lookup for that data yet. This is some pretty slick stuff, I may have to dwell into the source to see how it works. Gotta watch out for your session scope though. It took me some messing before I starting getting the whole detached stuff and reconnecting them back to a persistent state. I’m very happy that I’m figuring this stuff out on my own.
One thing that I haven’t found anywhere is what the best practice is for returning a list from a query (ex. .list() ) in Java 1.5+ in regards to generics. For instance if I do
List list = session.createQuery("from Person").list();
I get a warning that I should use a parameterized list. So if I switch it to this, which is how I’d prefer it
List<Person> list = session.createQuery("from Person").list();
it warns me that this is an unchecked conversion. Looking through the Caveat Emptor application, they suppress the unchecked warnings. So I’m guessing that’s the suggested practice. I may go hunting for an open source project that makes use of it to see what someone else does.
My plans from here are to continue looking through the core documentation, start exploring the Caveat Emptor app, and start coming up with my own mapping files for different situations.
On this day…
- 2010: The beast that made me forget my MacBook — Maybe I’ve talked about my current work laptop before, maybe not. I don’t think so.
I posted how much I was [...] - 2005: Friday! — Not much going on today. Did some extreme grilling tonight for a pretty big meal by our standards. [...]
Related posts:
- The Part Time Developer 6: Adding Hibernate to the Spring Tutorial The code formatting in this post is crap. I’ve been...
- The Part Time Developer 2: The Beginning So here’s a recap of my first week of renewing...
- The Part Time Developer 5: Spring So now that I’m relatively back in the land of...
- The Part Time Developer 1: Explanation I apologize for the incoherence of my last post. I...
- Part Time Developer No More! You read the headline correctly, I am going to be...
Related posts brought to you by Yet Another Related Posts Plugin.
Tags: hibernate, parttimedeveloper