发表于: 2018-06-10 23:00:25

3 811


今天完成的事情:(一定要写非常细致的内容,比如说学会了盒子模型,了解了Margin) 

熟悉开发环境,对jpa做了小的demo,对常用的数据库操作方法熟悉下。


对形如

List<User> findByEmailAddressAndLastname(String emailAddress, String lastname);

这样的方法可以直接被解析。


Supported keywords inside method names


KeywordSampleJPQL snippet

And

findByLastnameAndFirstname

… where x.lastname = ?1 and x.firstname = ?2

Or

findByLastnameOrFirstname

… where x.lastname = ?1 or x.firstname = ?2

Is,Equals

findByFirstname,findByFirstnameIs,findByFirstnameEquals

… where x.firstname = ?1

Between

findByStartDateBetween

… where x.startDate between ?1 and ?2

LessThan

findByAgeLessThan

… where x.age < ?1

LessThanEqual

findByAgeLessThanEqual

… where x.age <= ?1

GreaterThan

findByAgeGreaterThan

… where x.age > ?1

GreaterThanEqual

findByAgeGreaterThanEqual

… where x.age >= ?1

After

findByStartDateAfter

… where x.startDate > ?1

Before

findByStartDateBefore

… where x.startDate < ?1

IsNull

findByAgeIsNull

… where x.age is null

IsNotNull,NotNull

findByAge(Is)NotNull

… where x.age not null

Like

findByFirstnameLike

… where x.firstname like ?1

NotLike

findByFirstnameNotLike

… where x.firstname not like ?1

StartingWith

findByFirstnameStartingWith

… where x.firstname like ?1(parameter bound with appended %)

EndingWith

findByFirstnameEndingWith

… where x.firstname like ?1(parameter bound with prepended %)

Containing

findByFirstnameContaining

… where x.firstname like ?1(parameter bound wrapped in %)

OrderBy

findByAgeOrderByLastnameDesc

… where x.age = ?1 order by x.lastname desc

Not

findByLastnameNot

… where x.lastname <> ?1

In

findByAgeIn(Collection<Age> ages)

… where x.age in ?1

NotIn

findByAgeNotIn(Collection<Age> ages)

… where x.age not in ?1

True

findByActiveTrue()

… where x.active = true

False

findByActiveFalse()

… where x.active = false

IgnoreCase

findByFirstnameIgnoreCase

… where UPPER(x.firstame) = UPPER(?1)


@Query注解


@Query("select u from User u where u.emailAddress = ?1") 

User findByEmailAddress(String emailAddress);

@Query("select u from User u where u.emailAddress like %?1") 

User findByEmailAddress(String emailAddress);


这样可以以sql语句来操作。



建好了项目的框架。

明天计划的事情:(一定要写非常细致的内容) 

写后台的文章模块

遇到的问题:(遇到什么困难,怎么解决的)

jpa只查询两个字段的时候 

收获:(通过今天的学习,学到了什么知识)

jpa的一些使用方法


返回列表 返回列表
评论

    分享到