public TitlesDepartmentUnitUnitGroup findByTitlesDepartmentUnitUnitGroup(
     Titles titles, Department department, Unit unit, UnitGroup unitGroup) {
   if (department == null) return null;
   long departmentId = department.getDepartmentId();
   long unitId = unit != null ? unit.getUnitId() : 0L;
   long unitGroupId = unitGroup != null ? unitGroup.getUnitGroupId() : 0L;
   long titlesId = titles.getTitlesId();
   return findByTitlesDepartmentUnitUnitGroup(titlesId, departmentId, unitId, unitGroupId);
 }
  public TitlesDepartmentUnitUnitGroup addTitlesDepartmentUnitUnitGroup(
      Titles titles,
      Department department,
      Unit unit,
      UnitGroup unitGroup,
      ServiceContext serviceContext) {
    if (department == null) return null;
    long departmentId = department.getDepartmentId();
    long unitId = unit != null ? unit.getUnitId() : 0L;
    long unitGroupId = unitGroup != null ? unitGroup.getUnitGroupId() : 0L;

    return addTitlesDepartmentUnitUnitGroup(
        titles.getTitlesId(), departmentId, unitId, unitGroupId, serviceContext);
  }