Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would build the architecture on top of the Spring Data JPA module. That would leave you with one class for the entity and one interface (under normal circumstances) for the repository.</p> <p>For more information take a look at the <a href="http://static.springsource.org/spring-data/data-jpa/docs/current/reference/html/" rel="nofollow">Spring docs</a>.</p> <p><strong>Shortened Example:</strong></p> <p>Spring config:</p> <pre><code>&lt;!-- Directory to scan for repository classes --&gt; &lt;jpa:repositories base-package="x.y.z.repositories" /&gt; &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt; &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt; &lt;property name="jpaDialect"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="jpaVendorAdapter"&gt; &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt; &lt;property name="generateDdl" value="true" /&gt; &lt;property name="database" value="HSQL" /&gt; &lt;/bean&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>Entity:</p> <pre><code>@Entity public class Product { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") private Long id; @NotNull private String name; } </code></pre> <p>Repository:</p> <pre><code>public interface ProductRepository extends CrudRepository&lt;Product, Long&gt; { public List&lt;Product&gt; findByName(String name); } </code></pre> <p>In order to use the repository, you simply need to inject it:</p> <pre><code>@Autowired private ProductRepository productRepository; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload