fix formatting of two code examples in intro
This commit is contained in:
parent
c85cd22956
commit
f278923c60
|
@ -757,13 +757,17 @@ For the most simple cases, Hibernate can infer the shape of the result set:
|
|||
|
||||
[source, java]
|
||||
----
|
||||
Book book = session.createNativeQuery("select * from Books where isbn = ?1", Book.class).getSingleResult();
|
||||
Book book =
|
||||
session.createNativeQuery("select * from Books where isbn = ?1", Book.class)
|
||||
.getSingleResult();
|
||||
|
||||
String title = session.createNativeQuery("select title from Books where isbn = ?1", String.class).getSingleResult();
|
||||
String title =
|
||||
session.createNativeQuery("select title from Books where isbn = ?1", String.class)
|
||||
.getSingleResult();
|
||||
----
|
||||
|
||||
However, in general, there isn't enough information in the JDBC `ResultSetMetaData` to infer the mapping of columns to entity objects.
|
||||
So for more complicated cases, you'll need to use the `@SqlResultSetMapping` annotation to define a named mapping, and pass the name to `createNativeQuery()`.
|
||||
So for more complicated cases, you'll need to use the `@SqlResultSetMapping` annotation to define a named mapping, and pass the name to `createNativeQuery()`. This gets fairly messy, so we don't want to hurt your eyes by showing you an example of it.
|
||||
|
||||
By default, Hibernate doesn't flush the session before execution of a native query.
|
||||
That's because the session is unaware of which modifications held in memory would affect the results of the query.
|
||||
|
@ -789,7 +793,7 @@ List<Book> books =
|
|||
.getResultList()
|
||||
----
|
||||
|
||||
Or, alternative, we could tell Hibernate which modified state affects the results of the query:
|
||||
Or, alternatively, we could tell Hibernate which modified state affects the results of the query:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
|
|
Loading…
Reference in New Issue