-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: association getters returning null with access="field&q
PostPosted: Mon Feb 23, 2009 2:36 am 
Newbie

Joined: Mon Feb 23, 2009 2:12 am
Posts: 1
It looks like I'm experiencing cases here in which calling an association getter on a mapped object in persistent state returns null even though the association exists in the database. This shouldn't happen, right? However, I have the access="field" attribute set in the Hibernate mapping file for all properties and associations (there's just a default-access="field" declaration for the whole file). It seems somewhat logical that these null returns would happen in such a scenario because (I imagine) Hibernate can't intercept field accesses. Can anyone confirm this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 6:52 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
I can't think of any way to intercept field access in Java, can you?

Anyway, hibernate does not need to intercept field access (even if you use access type field), because it does not place null-values instead of associated objects replacing them when you access them via getter. Actually, hibernate places proxies instead, so there will never be a null value if an association exists.

There has to be some other problem with your mapping/code. Maybe we can help, if you post it.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.