[jboss-dev-forums] [EJB3 Development] - onetomany problem with null values in arraylist

John Strandmyr do-not-reply at jboss.com
Wed Jan 19 06:43:22 EST 2011


John Strandmyr [http://community.jboss.org/people/strandmyr] created the discussion

"onetomany problem with null values in arraylist"

To view the discussion, visit: http://community.jboss.org/message/581805#581805

--------------------------------------------------------------
               Hi, this is my first post, so i hope im doing this right.

I have three entities that belong in a hiarchy. The entities are Prosess, ProsessTrinn and ProsessTrinnFare


defined in Prosess is:

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn (name="prosess_id")
public List<ProsessTrinn> prosessTrinn = new ArrayList<ProsessTrinn>();

This works fine.

In ProsessTrinn I have:

@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn (name="prosesstrinn_id")
@IndexColumn(name="id")    
public List<ProsessTrinnFare> farer = new ArrayList<ProsessTrinnFare>();

What happens is that all data is loaded, but a lot of null values are inserted in each of the arraylists. If i have 1 Prosess, 4 ProsessTrinn and each of those have 1 ProsessTrinnFare each, it results in 1, 2, 3 and 4 null values in the ArrayList. It may seem like the last entity to be loaded is inserted by index, and not reseting index for each of the Arraylists, causing there to be 1, 2, 3 and 4 null-values.

I know i can loop the arraylist on the getter, and remove null-values but seems like i've done something wrong and i'd rather correct that.

I'd apprechiate any hints and tips
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/581805#581805]

Start a new discussion in EJB3 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2030]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20110119/55f5712d/attachment.html 


More information about the jboss-dev-forums mailing list