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&...]