jpa笔记
使用序列:
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_user_serialno")
@SequenceGenerator(name = "seq_user_serialno", sequenceName = "SEQ_USER_SERIALNO", allocationSize = 1)
分页配置:
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
service:
Page<User> userPage= userDao.findByName(kindCode,PageRequest.of(1,2, Sort.Direction.ASC,"id","kindCode"));//排序为可选参数,排序字段至少一个
dao:
@Query(value="select * from User c where c.kindCode =:name ", nativeQuery = true)
Page<User> findByName(@Param("name") String name2, Pageable pageable);
spring:
jpa:
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.OracleDialect