小编Shr*_*ser的帖子

在Spring Data Neo4j 4中进行分页和排序

在SDN4中是否有对自定义查询的分页支持?

  • 如果是,它是如何工作的?
  • 如果不是,那还有工作吗?

我有以下Spring Data Neo4j 4存储库:

@Repository
public interface TopicRepository 
  extends GraphRepository<Topic>,IAuthorityLookup {

  // other methods omitted
  @Query("MATCH (t:Topic)-[:HAS_OFFICER]->(u:User) "
    + "WHERE t.id = {0} "
    + "RETURN  u")
  public Page<User> topicOfficers(Long topicId, Pageable pageable);
}
Run Code Online (Sandbox Code Playgroud)

和相应的测试用例:

@Test
public void itShouldReturnAllOfficersAsAPage() {
  Pageable pageable = new PageRequest(1,10);
  Page<User> officers = topicRepository.topicOfficers(1L, pageable);
  assertNotNull(officers);
}
Run Code Online (Sandbox Code Playgroud)

当我运行测试时,我遇到以下异常

Failed to convert from type java.util.ArrayList<?> to type   org.springframework.data.domain.Page<?> for value '[org.lecture.model.User@1]'; 
nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type …
Run Code Online (Sandbox Code Playgroud)

java spring neo4j spring-data-neo4j-4

9
推荐指数
2
解决办法
2261
查看次数

在Javafx中为新的ListView条目设置动画

问题

嗨,

我正在尝试编写一个应用程序,ListView中的每个新条目都会被动画化.这是我的代码:

public class BookCell extends ListCell<Book>
{
    private Text text;
    private HBox h;

    public BookCell()
    {
        this.text = new Text();
        this.h = new HBox();
        this.h.getChildren().add(text);
        super.getStyleClass().add("book-list-cell");
        super.itemProperty().addListener((obs,oldv,newv)->{
            if(newv != null )
            {
                if(getIndex() == this.getListView().getItems().size()-1 )
                {
                    //why does this get called twice for each update?
                    System.out.println("isbn = "+newv.getIsbn().get() + "   lastIndexOf=" + this.getListView().getItems().lastIndexOf(newv)+"    Index="+getIndex()+"   size="+this.getListView().getItems().size());
                    runAnimation();
                }
            }

        });
        this.getChildren().add(h);
    }
    @Override
    protected void updateItem(Book item, boolean empty)
    {
         super.updateItem(item, empty);
         if(!empty)
             super.setGraphic(h);
         text.setText(item == null ? …
Run Code Online (Sandbox Code Playgroud)

java animation listview javafx javafx-8

5
推荐指数
1
解决办法
1528
查看次数

如何使用 memmap crate 附加到文件支持的 mmap?

我有一个foo.txt包含内容的文件

foobar
Run Code Online (Sandbox Code Playgroud)

我想连续追加到该文件并有权访问修改后的文件。

MmapMut

我尝试的第一件事是直接改变 mmap:

use memmap;
use std::fs;
use std::io::prelude::*;

fn main() -> Result<(), Box<std::error::Error>> {
    let backing_file = fs::OpenOptions::new()
        .read(true)
        .append(true)
        .create(true)
        .write(true)
        .open("foo.txt")?;

    let mut mmap = unsafe { memmap::MmapMut::map_mut(&backing_file)? };

    loop {
        println!("{}", std::str::from_utf8(&mmap[..])?);
        std::thread::sleep(std::time::Duration::from_secs(5));
        let buf = b"somestring";
        (&mut mmap[..]).write_all(buf)?;
        mmap.flush()?;
    }
}
Run Code Online (Sandbox Code Playgroud)

这会导致恐慌:

use memmap;
use std::fs;
use std::io::prelude::*;

fn main() -> Result<(), Box<std::error::Error>> {
    let backing_file = fs::OpenOptions::new()
        .read(true)
        .append(true)
        .create(true)
        .write(true)
        .open("foo.txt")?;

    let mut mmap = unsafe { memmap::MmapMut::map_mut(&backing_file)? …
Run Code Online (Sandbox Code Playgroud)

linux mmap rust

5
推荐指数
1
解决办法
1199
查看次数