当前位置: 首页 > news >正文

极速网站建设定制费用wordpress导航模板下载

极速网站建设定制费用,wordpress导航模板下载,没有网怎么装wordpress,vultr部署wordpress我最近写了几篇有关Kotlin代表团的文章。 通过这样做#xff0c;我实现了一种将其应用于Spring Data存储库的有用方法。 这将使Spring Data在提供定制路线的同时继续散布一些魔力。 这篇文章中显示的代码在Kotlin中#xff0c;但仍然与Java有关。 这篇文章使用R2DBC#xf… 我最近写了几篇有关Kotlin代表团的文章。 通过这样做我实现了一种将其应用于Spring Data存储库的有用方法。 这将使Spring Data在提供定制路线的同时继续散布一些魔力。 这篇文章中显示的代码在Kotlin中但仍然与Java有关。 这篇文章使用R2DBC但是内容足够通用可以应用于任何Spring Data模块。 如果您在这些领域没有太多的背景知识那么在Kotlin中 使用Spring Data R2DBC和类委托读取异步RDBMS访问将是有益的。 作为回顾。 Spring Data提供的魔力是什么 Spring Data允许您编写一个仅需要定义所需查询的接口。 然后它将完成创建实现和为您注入依赖项的所有工作。 看起来像这样 Repository interface PersonRepository : R2dbcRepositoryPerson, Int { Query ( SELECT * FROM people WHERE age $1 ) fun findAllByAgeGreaterThan(age: Int): FluxPerson } 由于正在使用Spring Data R2DBC因此尚不完全支持完全推断的查询。 这就是为什么手动写出查询的原因。 不利的一面是它正在基于接口创建实现。 因此如果要进行任何类型的自定义则需要自己创建接口的实例注入其依赖关系并实现每个查询。 例如 class PersonRepositoryImpl( private val entity: RelationalEntityInformationPerson, Int, private val databaseClient: DatabaseClient, converter: R2dbcConverter, private val accessStrategy: ReactiveDataAccessStrategy ) : SimpleR2dbcRepositoryPerson, Int(entity, databaseClient, converter, accessStrategy), PersonRepository { override fun findAllByAgeGreaterThan(age: Int): FluxPerson { val mapper: StatementMapper.TypedStatementMapperPerson accessStrategy.statementMapper.forType(entity.javaType) val selectSpec: StatementMapper.SelectSpec mapper .createSelect(entity.tableName) .withProjection(accessStrategy.getAllColumns(entity.javaType)) .withCriteria(Criteria.where( age ).greaterThan(age)) val operation: PreparedOperation* mapper.getMappedObject(selectSpec) return databaseClient.execute().sql(operation).as(entity.javaType).fetch().all() } } 是的该查询代码可能很糟糕我相信您可以做得更好。 你明白我的意思。 可以通过委派基于您的接口实现的Spring仓库来消除创建此类的麻烦。 然后您可以添加所需的所有自定义。 在Kotlin中这看起来像 Repository class DelegatingPersonRepository( private val delegate: PersonRepository) : PersonRepository by delegate { override fun S : Person save(objectToSave: S): MonoS { // override save implementation } // any other overrides (kotlin provides delegated implementations) } 在Java中这比较麻烦但仍然可以轻松实现 Repository public class DelegatingPersonRepository implements PersonRepository { private final PersonRepository delegate; public DelegatingPersonRepository(PersonRepository delegate) { this .delegate delegate; } Override public FluxPerson findAllByAgeGreaterThan( int age) { return delegate.findAllByAgeGreaterThan(age); } Override public S extends Person MonoS save(S entity) { // override save implementation } // all other implementations of PersonRepository functions } 在这两个版本中 DelegatingPersonRepository调用PersonRepository定义的findAllByAgeGreaterThan的实现。 到目前为止还没有直接花费精力来编写查询数据库的功能。 使用DelegatingPersonRepository 所有未覆盖的函数调用将委托给Spring创建的PersonRepository的实现。 对于像我这样的人他真的不喜欢将SQL查询放在一起并编写所有转换代码。 通过这种方式使用委派确实可以使您充分利用Spring Data的优势同时仍然为您提供自定义结果的空间。 您节省的代码量实际上可能不是那么大。 但是将其组合在一起所需的工作量大大减少了。 让Spring为您完成所有繁重的工作 翻译自: https://www.javacodegeeks.com/2019/09/augmenting-spring-data-repository-delegation.html
http://www.zqtcl.cn/news/511666/

相关文章:

  • 专门做设计的网站互联网运营培训班哪个好
  • 烟台网站建设网站推广做网站与数据库的关系
  • 深圳网站设计成功刻成全视频免费观看在线看第7季高清
  • 淮阳城乡建设局网站seo技术团队
  • 建设博客网站游戏交易类网站seo怎么做
  • 做系统软件的网站wordpress网站会员太多
  • 上海门户网站怎么登录网站开发竞价单页
  • 东莞市外贸网站建设公司软件开发 系统开发 网站开发服务
  • 泉州制作网站设计南宁网站排名外包
  • 南通网站建设入门wordpress google seo
  • 怎么建立图片的网站吗网站响应式是什么意思
  • 网站建设买了服务器后怎么做WordPress多城市
  • 网站建设凭证成都网站设计公司
  • 创新创业营销策略网站建设等做钢材的都用什么网站
  • 英文免费网站模板大庆+网站建设
  • 品牌网站建设内容框架网站首页收录没了
  • 湖南城乡住房建设厅网站网站图片切换效果
  • 凡科做的网站可以在百度搜到吗阿里云nas做网站
  • 做企业销售分析的网站更改wordpress传文件尺寸
  • 网站建设策划书封面知名企业名称
  • 中小企业网站建设与管理课件百度云济南高端网站建设公司
  • 台州企业建站程序网页设计素材网站知乎
  • wordpress视频付费谷歌seo专员是指什么意思
  • 域名续费做网站wordpress模板淘宝客模板
  • 加强政协机关网站建设深圳教育软件app开发
  • 绍兴企业网站推广Django 个人博客网站开发
  • html5 开发网站图门市建设局网站
  • wordpress 建立网站江苏电信网站备案
  • 企业网站能个人备案吗成都蜀美网站建设
  • 网站开发 占位符直播网站开发接入视频