Hi! I have a base class Activity and two classes inheriting it, MovementActivity and DurationActivity. MovementActivity contains two ArrayLists, activitiesBefore and activitiesAfter, both containing DurationActivity.
private List<DurationActivity> activitiesBefore = new ArrayList<DurationActivity>(); private List<DurationActivity> activitiesAfter = new ArrayList<DurationActivity>();
The annotations are in MovementActivity:
@OneToMany(orphanRemoval = true) @IndexColumn(name = "actBefore_idx", base = 0) @JoinColumn(name = "movementActivity_id") //@Where(clause="actBefore_idx != null") @Cascade({org.hibernate.annotations.CascadeType.ALL}) public List<DurationActivity> getActivitiesBefore() { return activitiesBefore; } resp. @OneToMany(orphanRemoval = true) @IndexColumn(name = "actAfter_idx", base = 0) @JoinColumn(name = "movementActivity_id") //@Where(clause="actAfter_idx != null") @Cascade({org.hibernate.annotations.CascadeType.ALL}) public List<DurationActivity> getActivitiesAfter() { return activitiesAfter; }
The annotation in DurationActivity is:
@ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "movementActivity_id", insertable = false, updatable = false) public MovementActivity getMovementActivity() { return movementActivity; }
A while ago I only had the first list and everything worked fine, but after the introduction of the second list a exception is thrown: org.hibernate.HibernateException: null index column for collection: MovementActivity.activitiesAfter at the instant a list of parents (MovementActivity) is read from DB. No effort to read any data has been made, just the single line: List retList = query.list();
A DurationActivity object is created and stored i DB with actBefore_idx set to 0, and actAfter_idx set to null. As you see above, I have tried with the where clause, and then the list comes up without exception, but no child objects tied to the parent.
I want to be able to randomly insert objects in either of the lists, or none.
Is there a way to get pass this, with annotations?
|