Coder Social home page Coder Social logo

Comments (7)

handeyeco avatar handeyeco commented on August 14, 2024 19

Actually ended up changing:

return this.bookmarkRepository.findOne(bookmarkId);

to:

Optional<Bookmark> bookmark = this.bookmarkRepository.findById(bookmarkId);
if (bookmark.isPresent()) {
    return bookmark.get();
} else {
    return null;
}

The application compiles and runs as expected so far. Would love feedback on whether this is the way to go or not.

from tut-rest.

VictorSago avatar VictorSago commented on August 14, 2024 4

@RaMdsC
This might indeed be the case. Looking at the documentation for Spring v1.5.x the method findOne() is inherited from the CrudRepository interface and has the signature:

T findOne(ID id)

while in the current version of Spring this method is inherited from QueryByExampleExecutor and has the signature:

<S extends T> Optional<S> findOne(Example<S> example)

In the current implementation of CrudRepository this method does not exist.

from tut-rest.

davidjlynn avatar davidjlynn commented on August 14, 2024

+1

from tut-rest.

RaMdsC avatar RaMdsC commented on August 14, 2024

+1

from tut-rest.

VictorSago avatar VictorSago commented on August 14, 2024

Had exactly the same problem. Also tried to replace findOne(bookmarkId) with getOne(bookmarkId). Ended up with the same solution as @matthewbryancurtis - using an Optional and returning null when there is no bookmark. Even though it doesn't seem right to return null when the method declares Bookmark as the return type.

But here is the funny thing. A slightly elder version of the same tutorial found here: https://github.com/joshlong/bookmarks/tree/tutorial does compile (in the end, if skipTests is set) and can be made to run as expected. Don't know why.

from tut-rest.

RaMdsC avatar RaMdsC commented on August 14, 2024

Tested and working straightaway on clean Ubuntu 17.10.
Apache Maven 3.5.0
OpenJDK 1.8.0_171
Maven defaults to Spring Boot v1.5.1.RELEASE

I will post further updates as i do some more testing, it seems like an incompatibility issue.

UPDATE 1:
Tested and also working straightaway on clean Ubuntu 16.04.
Apache Maven 3.3.9
OpenJDK 1.8.0_171
Maven defaults to Spring Boot v1.5.1.RELEASE

from tut-rest.

gregturn avatar gregturn commented on August 14, 2024

Resolved via 7f3644e

from tut-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.