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;
}
How can I store the data fetch by @Query(...) in ActiveSession Object Or is there any other way? I tried storing data into object (i.e List<Object>) but I'm using ftl for view and it does not allow you fetch the data unless the object have getters.