Search code examples
speedment

How can I see the SQL code Speedment sends to the database?


When I create and use a stream with Speedment, how can I see what is sent to the database? For example, if I try the first example on GitHub:

Optional<Film> longFilm = films.stream()
    .filter(Film.LENGTH.greaterThan(120))
    .findAny();

Solution

  • You can see the queries generated by attaching a logger to the builder when you first setup the Speedment Application.

    final DemoApplication app = new DemoApplicationBuilder()
            .withLogging(ApplicationBuilder.LogType.STREAM)
            .build();
    

    Now when you invoke .findAny(), the generated SQL query will be shown in the output.