-->
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: Collection being retreived as NULL
PostPosted: Fri Mar 07, 2008 2:41 pm 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
I have switched over our application from hbm.xml files to annotations and find that a collection is being retreived as NULL. My understanding is that this is AlWAYS a bug, and that the collection should come back as empty in some cases but never null.

Is that correct?

The collection is nested inside a couple containers so there are two levels of eager fetching going on, if that matters.


Here are mapping files and more info:

Hibernate version:
3.2.5 core + 3.2.5 annotations

Mapping documents:
Code:
class Victim
@OneToMany(fetch=FetchType.LAZY, targetEntity=com.app.VictimInfo.class, mappedBy = "victim")
    public Set getVictimInfos() {
        return this.victimInfos;
    }

class VictimInfo...
  @ManyToOne
    @JoinColumn(name="Victim_GUID")
    public com.app.Victim getVictim() {
        return this.victim;
    }


specifically, I get a null pointer exception when trying to process victim.getInfos() in some way. Our code assumes the collection may be empty but will never be null.


Top
 Profile  
 
 Post subject: Fixed -- there was an @Transient
PostPosted: Fri Mar 07, 2008 5:55 pm 
Regular
Regular

Joined: Wed Dec 21, 2005 6:57 pm
Posts: 70
A previous method was commented out resulting in an @Transient preceding the actual annotations. Apparently @Transient overrides @OneToMany annotations, so it was set to NULL.

FYI, if you're reading this, a NULL collection indicates an errant @Transient tag.


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.