You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
1.0 KiB

package app.services.db;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@Service
public class DBService {
EntityManager entityManager_rw;
EntityManager entityManager_ro;
@Autowired
public DBService(
@Qualifier(value = "RwEntityManager") EntityManager entityManager_rw,
@Qualifier(value = "RoEntityManager") EntityManager entityManager_ro
) {
this.entityManager_rw = entityManager_rw;
this.entityManager_ro = entityManager_ro;
}
public Long getDBServerTime() {
Long rw_time = (Long) entityManager_rw.createNativeQuery("SELECT UNIX_TIMESTAMP()")
.getSingleResult();
Long ro_time = (Long) entityManager_ro.createNativeQuery("SELECT UNIX_TIMESTAMP()")
.getSingleResult();
return rw_time;
}
}