title: Create JPA Specification object in Kotlin
body: <p>I want to filter on a specific name by using JPA Specifications.</p>
  
  <p>My Repository extends from JpaSpecificationExecutor&lt;>.</p>
  
  <p>I can't figur out how to make a Specification Object. I got the following code:</p>
  
  <pre><code>@Service
  class FlightService(private val flightRepository: FlightRepository,
                     private val em: EntityManager) {
  
  fun hasName(name: String): Specification&lt;Flight&gt; {
      val cb = em.criteriaBuilder
      val cq = cb.createQuery(Flight::class.java)
      val root : Root&lt;Flight&gt; = cq.from(Flight::class.java)
      return { root, cq, cb -&gt; cb.equal(root.get("name"), name) }
  }
  </code></pre>
  
  <p>Any idea what i'm doing here wrong? I need this specification object for the findAll method.</p>