小编lit*_*olf的帖子

Spring Data JPA 存储库 findAll() 空指针

我有一个 Spring-Boot API,其端点如下。它在 Spring Data JPA 查询上抛出空指针异常findAll;当我注释掉这一行时,我没有收到任何错误。看来我从存储库查询中得到了空结果,但我知道数据是通过直接查询数据库而存在的。我不明白为什么我得到的变量为空topicsLookup...任何人都可以指出我正确的方向吗?

资源:

@RequestMapping(value = "/lectures/{lectureId}",
        method = RequestMethod.GET,
        produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, SpeakerTopicLectures> getLecture(@PathVariable Long lectureId){

        Long requestReceived = new Date().getTime();
        Map<String, SpeakerTopicLectures> result = new HashMap<>();

        log.debug("** GET Request to getLecture");
        log.debug("Querying results");

        List<SpeakerTopicLectures> dataRows = speakerTopicLecturesRepository.findBySpeakerTopicLecturesPk_LectureId(lectureId);

        // This line throws the error
        List<SpeakerTopic> 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 …
Run Code Online (Sandbox Code Playgroud)

java hibernate spring-data-jpa spring-boot

3
推荐指数
1
解决办法
1万
查看次数

为什么这个style.display不起作用?

为什么这不起作用?它应该检查displaycss样式的元素.

if (byId("annonsera_price").style.display=='inline' || byId("annonsera_price").style.display=='block'){
alert ("Hello");
}

function byId(x){
        return document.getElementById(x);
}
Run Code Online (Sandbox Code Playgroud)

UPDATE2:

<input style="width:100px;" type="text" name="annonsera_price" id="annonsera_price">
Run Code Online (Sandbox Code Playgroud)

我也没有用css设置它!

html javascript

2
推荐指数
1
解决办法
6227
查看次数

无法循环骨干集合

似乎我无法遍历骨干集合.我已经在几个主题中看过这个主题,但这些解决方案都没有帮助.

render:function () {
        this.$el.html(this.template(this.model.attributes));
        var that = this;


        console.log(this.projects.models);
        _.each(this.projects.models, function(model) { console.log(model); });

        return this;
    }
Run Code Online (Sandbox Code Playgroud)

从这个我的控制台只显示数组[2]我希望看到每个模型.有谁知道我在这里做错了什么?

backbone.js underscore.js backbone.js-collections

2
推荐指数
1
解决办法
5082
查看次数