eventId and userId are fks in slideshow table. By default User and Event should be lazy loaded to SlideShow by proxy. Hence, I should be able to get eventId and userId from slideShow.getEvent().getEventId() However, the eventId is null when I step through the proxy object in debugger. Same is true for userId. Am I missing something? Should the proxy object has the id of the associate object loaded lazily? How does one retrieve it? Thank you for all your help.
Yes, that's the code. Does whether lazy initialization happened depends on the default of the mapping? ie. @ManyToOne default lazy so it will get exception; @OneToOne won't because default is eager. What determine if hibernate will run the extra select to get the association. I am still a little confused with any solid rule.
Thank you very much for your answer. I am a big fan of your book. It is my "the book" for for me in using hibernate. I get more every time I read it over.
Assuming everything is lazy, the slideshow will be pulled from the db when it is requested the first time, but the event will not. When the event is first called with a getter, it should be pulled with all of its attributes. So, if getEvent() doesn't return null, the event must have been loaded. If getEvent().getEventId() returns null, the event is not null, but for some reason the eventId is.