DATACMNS-144 - Polished reference docs on repositories.
Made clear that the usages of the JPA namespace are a convenience artifact to keep the sample code copyable as much as possible but need to be tweaked in case one uses repositories with a different store. Added language attributes to code snippets where missing.
This commit is contained in:
@@ -20,7 +20,9 @@
|
||||
significantly.</para>
|
||||
|
||||
<para>The following chapters will introduce the core concepts and
|
||||
interfaces of Spring Data repositories.</para>
|
||||
interfaces of Spring Data repositories in general for detailled
|
||||
information on the specific features of a particular store consult the
|
||||
later chapters of this document.</para>
|
||||
</section>
|
||||
|
||||
<section id="repositories.core-concepts">
|
||||
@@ -123,7 +125,7 @@
|
||||
<para>Accessing the second page of <classname>User</classname> by a page
|
||||
size of 20 you could simply do something like this:</para>
|
||||
|
||||
<programlisting>PagingAndSortingRepository<User, Long> repository = // … get access to a bean
|
||||
<programlisting language="java">PagingAndSortingRepository<User, Long> repository = // … get access to a bean
|
||||
Page<User> users = repository.findAll(new PageRequest(1, 20);</programlisting>
|
||||
</section>
|
||||
|
||||
@@ -165,6 +167,14 @@ Page<User> users = repository.findAll(new PageRequest(1, 20);</programlist
|
||||
<repositories base-package="com.acme.repositories" />
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<note>
|
||||
<para>Note that we use the JPA namespace here just by example. If
|
||||
you're using the repository abstraction for any other store you need
|
||||
to change this to the appropriate namespace declaration of your
|
||||
store module which should be exchanging <code>jpa</code> in favor of
|
||||
e.g. <code>mongodb</code>.</para>
|
||||
</note>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
@@ -215,7 +225,7 @@ Page<User> users = repository.findAll(new PageRequest(1, 20);</programlist
|
||||
<example>
|
||||
<title>Selectively exposing CRUD methods</title>
|
||||
|
||||
<programlisting>interface MyBaseRepository<T, ID extends Serializable> extends Repository<T, ID> {
|
||||
<programlisting language="java">interface MyBaseRepository<T, ID extends Serializable> extends Repository<T, ID> {
|
||||
T findOne(ID id);
|
||||
T save(T entity);
|
||||
}
|
||||
@@ -512,7 +522,7 @@ List<User> findByLastname(String lastname, Pageable pageable);</programlis
|
||||
<example>
|
||||
<title>Standalone usage of repository factory</title>
|
||||
|
||||
<programlisting>RepositoryFactorySupport factory = … // Instantiate factory here
|
||||
<programlisting language="java">RepositoryFactorySupport factory = … // Instantiate factory here
|
||||
UserRepository repository = factory.getRepository(UserRepository.class);</programlisting>
|
||||
</example>
|
||||
</section>
|
||||
@@ -976,4 +986,4 @@ public class UserController {
|
||||
</simplesect>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
Reference in New Issue
Block a user