У меня есть API Spring-Boot с конечной точкой ниже. Он выдает исключение нулевого указателя в запросе Spring Data JPA findAll; когда я закомментирую эту строку, я не получаю ошибок. Кажется, что я получаю нулевой результат в результате запроса к репозиторию, но я знаю, что данные имеются в результате прямого запроса к БД. Я не могу понять, почему я получаю нулевое значение для переменной subjectLookup... Может ли кто-нибудь указать мне правильное направление?
Ресурс:< /strong>
@RequestMapping(value = "/lectures/{lectureId}",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public Map getLecture(@PathVariable Long lectureId){
Long requestReceived = new Date().getTime();
Map result = new HashMap();
log.debug("** GET Request to getLecture");
log.debug("Querying results");
List dataRows = speakerTopicLecturesRepository.findBySpeakerTopicLecturesPk_LectureId(lectureId);
// This line throws the error
List topicsLookup = speakerTopicsRepository.findAll();
// Do stuff here...
log.debug("Got {} rows", dataRows.size());
log.debug("Request took {}ms **", (new Date().getTime() - requestReceived));
// wrap lecture in map object
result.put("content", dataRows.get(0));
return result;
}
Java Bean:
@Entity
@Table(name = "speaker_topics")
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
public class SpeakerTopic implements Serializable {
@Id
@Column(name = "topic_id")
private Long topicId;
@Column(name = "topic_nm")
private String topicName;
@Column(name = "topic_desc")
private String topicDesc;
@Column(name = "topic_acm_relt_rsce")
private String relatedResources;
}
Репозиторий:
import org.acm.dl.api.domain.SpeakerTopic;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SpeakerTopicsRepository extends JpaRepository {
}
Подробнее здесь: https://stackoverflow.com/questions/453 ... ll-pointer
Репозиторий Spring Data JPA findAll() Нулевой указатель ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение