Skip to Content
Building Applications with Spring 5 and Kotlin
book

Building Applications with Spring 5 and Kotlin

by Miloš Vasić
May 2018
Intermediate to advanced
310 pages
6h 18m
English
Packt Publishing
Content preview from Building Applications with Spring 5 and Kotlin

Named queries

We will give one more example of querying data. We will introduce you to named queries. We will define named queries by using the @NamedQuery annotation applied to our entity class. To give you a better understanding of what we are talking about, we will extend our code. Open the Note class and extend it:

package com.journaler.api.data 
... 
@Entity 
@Table(name = "note") 
@JsonInclude(JsonInclude.Include.NON_NULL) 
@NamedQuery( 
        name = "Note.findByTitle", 
        query = "SELECT n FROM Note n WHERE n.title LIKE ?1" 
) 
data class Note( 
    ... 
) { 
    ... 
} 

We defined a query that will find all Notes with the title we provide as a parameter through API call. The method that will trigger a query is called findByTitle, so it must be defined in our ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java to Kotlin

Java to Kotlin

Duncan McGregor, Nat Pryce
Hands-On Microservices with Kotlin

Hands-On Microservices with Kotlin

Juan Antonio Medina Iglesias
Programming Kotlin

Programming Kotlin

Venkat Subramaniam

Publisher Resources

ISBN: 9781788394802