In the case of the existing range, the object dateRange is never set, it's still the 'new DateRange()' it was initialized on.
This should be better:
DateRange dateRange;
if(...){
dateRange = (DateRange)it.next();
}
else{
dateRange = new DateRange();
...
session.save(dateRange);
}
Also, you don't need to keep the dateRangeId, you can use the object itself in a Restriction, and it will take the id behind the screens:
criteria.add(Restrictions.eq("dateRange", dateRange));