jackmew / spring-data-jpa-jackmew

0 stars 0 forks source link

Basic Spring Data JPA #4

Open jackmew opened 9 years ago

jackmew commented 9 years ago

Spring Data JPA

You can create concrete repositories by creating repository interfaces and letting Spring Data JPA do all the heavy lifting.

Spring Data JPA Tutorial

using Hibernate as your JPA provider

jpaRepository : List<?> findAll()

image

so , I choose to extends jpaRepository .

CrudRepository

PagingAndSortingRepository

JpaRepository

Spring Data JPA - three types of Query

link

1. Query Creation from Method Name

According to method Name and transform to sql query.

function name mapping

2. JPA Named Queries

Code some sql query to Entity .

image

corresponding repository

image

It's a special way to do query , but maybe it's not practical.

3. @Query Annotation

image

Using this way can do a lot of elastic way to query .

I think 1 , 3 is enough.

Next goal is : like and date.