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

学做网站和推广要多久vivo官网网站服务

学做网站和推广要多久,vivo官网网站服务,搜索引擎优化是什么意思,wordpress开启多站点模式Spring Data是一个非常方便的库。 但是#xff0c;由于该项目是一个相当新的项目#xff0c;因此功能不佳。 默认情况下#xff0c;Spring Data JPA将基于SimpleJpaRepository提供DAO的实现。 在最近的项目中#xff0c;我开发了一个定制的存储库基类#xff0c;以便可以在… Spring Data是一个非常方便的库。 但是由于该项目是一个相当新的项目因此功能不佳。 默认情况下Spring Data JPA将基于SimpleJpaRepository提供DAO的实现。 在最近的项目中我开发了一个定制的存储库基类以便可以在其上添加更多功能。 您可以根据需要向该存储库基类添加特定于供应商的功能。 组态 您必须在spring bean配置文件中添加以下配置。 您必须指定一个新的存储库工厂类。 我们将在以后开发课程。 jpa:repositories base-packageexample.borislam.dao factory-classexample.borislam.data.springData.DefaultRepositoryFactoryBean/ 只需开发一个扩展JpaRepository的接口即可。 您应该记得用NoRepositoryBean对其进行注释。 NoRepositoryBean public interface GenericRepository T, ID extends Serializable extends JpaRepositoryT, ID { } 定义自定义存储库基础实现类 下一步是开发定制的基础存储库类。 您可以看到我只是这个自定义基础存储库中的一个属性即springDataRepositoryInterface。 我只想对存储库接口的自定义行为的行为进行更多控制。 在下一篇文章中我将展示如何添加此基础存储库类的更多功能。 SuppressWarnings(unchecked) NoRepositoryBean public class GenericRepositoryImplT, ID extends Serializable extends SimpleJpaRepositoryT, ID implements GenericRepositoryT, ID , Serializable{private static final long serialVersionUID 1L;static Logger logger Logger.getLogger(GenericRepositoryImpl.class);private final JpaEntityInformationT, ? entityInformation;private final EntityManager em;private final DefaultPersistenceProvider provider;private Class? springDataRepositoryInterface; public Class? getSpringDataRepositoryInterface() {return springDataRepositoryInterface;}public void setSpringDataRepositoryInterface(Class? springDataRepositoryInterface) {this.springDataRepositoryInterface springDataRepositoryInterface;}/*** Creates a new {link SimpleJpaRepository} to manage objects of the given* {link JpaEntityInformation}.* * param entityInformation* param entityManager*/public GenericRepositoryImpl (JpaEntityInformationT, ? entityInformation, EntityManager entityManager , Class? springDataRepositoryInterface) {super(entityInformation, entityManager);this.entityInformation entityInformation;this.em entityManager;this.provider DefaultPersistenceProvider.fromEntityManager(entityManager);this.springDataRepositoryInterface springDataRepositoryInterface;}/*** Creates a new {link SimpleJpaRepository} to manage objects of the given* domain type.* * param domainClass* param em*/public GenericRepositoryImpl(ClassT domainClass, EntityManager em) {this(JpaEntityInformationSupport.getMetadata(domainClass, em), em, null); }public S extends T S save(S entity){ if (this.entityInformation.isNew(entity)) {this.em.persist(entity);flush();return entity;}entity this.em.merge(entity);flush();return entity;}public T saveWithoutFlush(T entity){return super.save(entity);}public ListT saveWithoutFlush(Iterable? extends T entities){ListT result new ArrayListT();if (entities null) {return result;}for (T entity : entities) {result.add(saveWithoutFlush(entity));}return result;} } 作为一个简单的示例我只是覆盖了SimpleJPARepository的默认保存方法。 持久保存后save方法的默认行为不会刷新。 我进行了修改以使其在持久化后保持刷新状态。 另一方面我添加了另一个名为saveWithoutFlush的方法以允许开发人员调用保存实体而无需刷新。 定义自定义存储库工厂bean 最后一步是创建一个工厂bean类和一个工厂类以根据您自定义的基本存储库类来生成存储库。 public class DefaultRepositoryFactoryBean T extends JpaRepositoryS, ID, S, ID extends Serializableextends JpaRepositoryFactoryBeanT, S, ID {/*** Returns a {link RepositoryFactorySupport}.* * param entityManager* return*/protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {return new DefaultRepositoryFactory(entityManager);} }/*** * The purpose of this class is to override the default behaviour of the spring JpaRepositoryFactory class.* It will produce a GenericRepositoryImpl object instead of SimpleJpaRepository. * */ public class DefaultRepositoryFactory extends JpaRepositoryFactory{private final EntityManager entityManager;private final QueryExtractor extractor;public DefaultRepositoryFactory(EntityManager entityManager) {super(entityManager);Assert.notNull(entityManager);this.entityManager entityManager;this.extractor DefaultPersistenceProvider.fromEntityManager(entityManager);}SuppressWarnings({ unchecked, rawtypes })protected T, ID extends Serializable JpaRepository?, ? getTargetRepository(RepositoryMetadata metadata, EntityManager entityManager) {Class? repositoryInterface metadata.getRepositoryInterface();JpaEntityInformation?, Serializable entityInformation getEntityInformation(metadata.getDomainType());if (isQueryDslExecutor(repositoryInterface)) {return new QueryDslJpaRepository(entityInformation, entityManager);} else {return new GenericRepositoryImpl(entityInformation, entityManager, repositoryInterface); //custom implementation}}Overrideprotected Class? getRepositoryBaseClass(RepositoryMetadata metadata) {if (isQueryDslExecutor(metadata.getRepositoryInterface())) {return QueryDslJpaRepository.class;} else {return GenericRepositoryImpl.class;}}/*** Returns whether the given repository interface requires a QueryDsl* specific implementation to be chosen.* * param repositoryInterface* return*/private boolean isQueryDslExecutor(Class? repositoryInterface) {return QUERY_DSL_PRESENT QueryDslPredicateExecutor.class.isAssignableFrom(repositoryInterface);} } 结论 现在您可以向基础存储库类添加更多功能。 在您的程序中您现在可以创建自己的存储库接口以扩展GenericRepository而不是JpaRepository。 public interface MyRepository T, ID extends Serializableextends GenericRepository T, ID {void someCustomMethod(ID id); } 在下一篇文章中我将向您展示如何向此GenericRepository添加休眠过滤器功能。 参考 “ 编程和平”博客上的JCG合作伙伴 Boris Lam 自定义Spring Data JPA存储库 。 翻译自: https://www.javacodegeeks.com/2012/08/customizing-spring-data-jpa-repository.html
http://www.yutouwan.com/news/383116/

相关文章:

  • 常州做网站企业某俄文网站
  • 综合性电子商务网站有哪些做做网站需要多少钱
  • 一级造价工程师报名网站wordpress 文章名
  • 廊坊做网站优化的公司网站优化优化怎么做
  • 备案过的网站换空间创意咨询策划公司
  • 福州网上商城网站建设一级a做爰片视频免费观看网站
  • 做国外搞笑网站ui设计师可以做到多少岁
  • 做付费动漫网站百度app官方下载安装到手机
  • 用asp做网站需要准备什么软件网络推广是干嘛的
  • 毕业设计做网站答辩会问什么网站建设所需服务器
  • 上海高登联合建设网站专业设计企业网站
  • 有没有一种app类似网站建设国土分局网站建设方案
  • vue框架做的网站三亚网红路
  • 专业网站设计都选亿企邦花18000去达内培训值吗
  • jsp网站开发广告位wordpress建站上海
  • 小企业网站建设的连接方式自己做视频网站怎么让加载速度变快
  • 嘉兴建设中心小学网站做gif动图的网站犯法吗
  • 网站流量盈利模式免费ppt模板下载软件有哪些
  • 做坑人网站二维码网站备案 如何填
  • 什么是企业营销型网站正规制作网站公司哪家好
  • 怎么做品牌推广网站高端品牌名字怎么取
  • 建站网站公司调查wordpress判断语句
  • 建设协会网站软件开发工具平台
  • 自建网站如何上传视频公司网站建设需要注意的地方
  • 经过开发建设 网站上线了net域名 著名网站
  • 丽水市住房和城乡建设局网站纯代码为WordPress添加
  • 全返利网站建设为什么无法再社保网站上做减员
  • mq网站开发乐清做网站价格
  • 网站建设前途做设计拍摄的网站平台
  • 网站换模板对seo可以做来电名片的网站