With the value of the primary key:

<BlockSwitcher>
<Block name="Java">

```java
Amplify.DataStore.query(Book.class, Where.identifier(Book.class, "12345"),
    matches -> {
        if (matches.hasNext()) {
            Book book = matches.next();
            Log.i("MyAmplifyApp", "Title: " + book.getTitle());
        }
    },
    failure -> Log.e("MyAmplifyApp", "Query failed.", failure));
```

</Block>
<Block name="Kotlin - Callback">

```kotlin
Amplify.DataStore.query(Book::class.java, Where.identifier(Book::class.java, "12345"),
    { allBooks: Iterator<Book> ->
        while (allBooks.hasNext()) {
            val book = allBooks.next()
            Log.i("MyAmplifyApp", "Title: " + book.title)
        }
                            },
   { failure: DataStoreException? -> Log.e("MyAmplifyApp", "Query failed.", failure) })
```

</Block>
<Block name="Kotlin - Coroutines (Beta)">

```kotlin
Amplify.DataStore.query(Book::class, Where.identifier(Book::class.java, "12345"))
    .catch { Log.e("MyAmplifyApp", "Query failed", it) }
    .collect { Log.i("MyAmplifyApp", "Title: ${it.title}") }
```

</Block>
<Block name="RxJava">

```java
RxAmplify.DataStore.query(Book.class, Where.identifier(Book::class.java, "12345")).subscribe(
    book -> Log.i("MyAmplifyApp", "Title: " + book.getTitle()),
    failure -> Log.e("MyAmplifyApp", "Query failed.", failure)
);
```

</Block>
</BlockSwitcher>

With the values of the composite key:

<BlockSwitcher>
<Block name="Java">

```java
Amplify.DataStore.query(Book.class, Where.identifier(Book.class,
    new BookIdentifier( "12345", "My Title")),
    matches -> {
        if (matches.hasNext()) {
            Book book = matches.next();
           Log.i("MyAmplifyApp", "Title: " + book.getTitle());
        }
    },
    failure -> Log.e("MyAmplifyApp", "Query failed.", failure));
```

</Block>
<Block name="Kotlin - Callback">

```kotlin
Amplify.DataStore.query(Book::class.java, Where.identifier(Book::class.java,
                                          BookIdentifier( "12345", "My Title")),
    { allBooks: Iterator<Book> ->
        while (allBooks.hasNext()) {
            val book = allBooks.next()
            Log.i("MyAmplifyApp", "Title: " + book.title)
        }
                            },
   { failure: DataStoreException? -> Log.e("MyAmplifyApp", "Query failed.", failure) })
```

</Block>
<Block name="Kotlin - Coroutines (Beta)">

```kotlin
Amplify.DataStore.query(Book::class, Where.identifier(Book::class.java,
        BookIdentifier( "12345", "My Title")))
  .catch { Log.e("MyAmplifyApp", "Query failed", it) }
  .collect { Log.i("MyAmplifyApp", "Title: ${it.title}") }
```

</Block>
<Block name="RxJava">

```java
RxAmplify.DataStore.query(Post.class, Where.identifier(Book::class.java,
                            new BookIdentifier( "12345", "My Title"))).subscribe(
    post -> Log.i("MyAmplifyApp", "Title: " + post.getTitle()),
    failure -> Log.e("MyAmplifyApp", "Query failed.", failure)
);
```

</Block>
</BlockSwitcher>


