【发布时间】:2021-08-15 21:08:09
【问题描述】:
JpaRepository
public interface SessionsStoreRepository extends JpaRepository<SessionsStore, Integer> {
SessionsStore findBySessionId(String sessionId);
//JPQL
@Query(value = "SELECT s.username,s.loginTime,s.logoutTime, e.firstName, e.lastName from SessionsStore s, Employee e "
+ " where e.username = s.username and s.isActive= 1")
List<ActiveSession> findUsers();
}
ActiveSession
import java.time.LocalDateTime;
import lombok.Data;
@Data
public class ActiveSession {
private String username;
private String firstName;
private String lastName;
private LocalDateTime loginTime;
private LocalDateTime logoutTime;
}
如何将@Query(...) 获取的数据存储在 ActiveSession 对象中或者还有其他方法吗?我尝试将数据存储到对象(即 List
【问题讨论】:
标签: spring-boot jpql freemarker