С бесперебойным питаловом есть вариант не только от 220v но и слаботочные
Выключать. банально командой "shutdown время". Это корректно все выключит, если ни какие службы не повисли.
По БД, можете и смонтировать папкой но зачем если БД умеет работать по сети..
@Query(value = "SELECT tss FROM TeacherSchoolSubject tss "
+ "INNER JOIN FETCH tss.teacher t "
+ "INNER JOIN FETCH tss.school sc "
+ "INNER JOIN FETCH tss.subject su "
+ "INNER JOIN FETCH sc.director d ", nativeQuery = false)
List<TeacherSchoolSubject> findAllTSSJoin();
select
teachersch0_.tss_id as tss_id1_3_0_,
appuser1_.appuser_id as appuser_1_0_1_,
school2_.school_id as school_i1_1_2_,
appuser4_.appuser_id as appuser_1_0_3_,
subject3_.subject_id as subject_1_2_4_,
teachersch0_.school as school2_3_0_,
teachersch0_.subject as subject3_3_0_,
teachersch0_.teacher as teacher4_3_0_,
appuser1_.fio as fio2_0_1_,
school2_.director as director3_1_2_,
school2_.school_number as school_n2_1_2_,
appuser4_.fio as fio2_0_3_,
subject3_.description as descript2_2_4_
from
teacher_school_subject teachersch0_
inner join
appuser appuser1_
on teachersch0_.teacher=appuser1_.appuser_id
inner join
school school2_
on teachersch0_.school=school2_.school_id
inner join
appuser appuser4_
on school2_.director=appuser4_.appuser_id
inner join
subject subject3_
on teachersch0_.subject=subject3_.subject_id
public List<TeacherSchoolSubject> getAll() {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<TeacherSchoolSubject> cq = cb.createQuery(TeacherSchoolSubject.class);
Root<TeacherSchoolSubject> tss = cq.from(TeacherSchoolSubject.class);
tss.fetch(TeacherSchoolSubject_.school, JoinType.INNER);
tss.fetch(TeacherSchoolSubject_.subject, JoinType.INNER);
tss.fetch(TeacherSchoolSubject_.teacher, JoinType.INNER);
TypedQuery<TeacherSchoolSubject> q = em.createQuery(cq);
List<TeacherSchoolSubject> resList = q.getResultList();
return resList;
}
select
teachersch0_.tss_id as tss_id1_3_0_,
school1_.school_id as school_i1_1_1_,
subject2_.subject_id as subject_1_2_2_,
appuser3_.appuser_id as appuser_1_0_3_,
teachersch0_.school as school2_3_0_,
teachersch0_.subject as subject3_3_0_,
teachersch0_.teacher as teacher4_3_0_,
school1_.director as director3_1_1_,
school1_.school_number as school_n2_1_1_,
subject2_.description as descript2_2_2_,
appuser3_.fio as fio2_0_3_
from
teacher_school_subject teachersch0_
inner join
school school1_
on teachersch0_.school=school1_.school_id
inner join
subject subject2_
on teachersch0_.subject=subject2_.subject_id
inner join
appuser appuser3_
on teachersch0_.teacher=appuser3_.appuser_id
select
appuser0_.appuser_id as appuser_1_0_0_,
appuser0_.fio as fio2_0_0_
from
appuser appuser0_
where
appuser0_.appuser_id=?
Вот только передавать сущности в сервисы, как бы моветон. Нужно преобразовывать через DTO в бизнес объекты.