草庐IT

QueryDSL-JPA

全部标签

java - 设置 Spring JPA 项目以在 MVC 项目中使用 - 创建 bean 时出错

我在Eclipse中开发了一个SpringJPA项目,它可以访问存储在mysql服务器中的数据。现在我需要在Spring@MVC项目中导入这个项目。所以:我在JPA项目的构建路径中配置导出maven依赖我将项目添加到了tomcat引导类路径中,我将JPA/Spring项目添加到我的Spring@MVC项目的类路径中我还将jpa应用程序上下文添加到MVC项目的根上下文中。当我尝试在tomcat服务器上运行应用程序时出现错误。似乎我缺少spring-beans库,但正如您在pom配置中看到的那样,我导入了它。这是错误日志:INFO:InitializingSpringrootWebAppl

java - spring-data-rest 发布的自定义 jpa 存储库方法

我已将自定义方法添加到jpa存储库,详细信息请参见http://docs.spring.io/spring-data/data-jpa/docs/1.0.x/reference/html/#repositories.custom-implementations据我所知,这个方法在我使用spring-data-rest时没有暴露出来。有什么方法可以将它作为spring-data-rest生成的RESTAPI的一部分发布(无需自己创建SpringMVCController)? 最佳答案 我检查了代码库-似乎他们明确禁用了自定义方法-不知

Spring 数据 JPA : How to update a model elegantly?

我的模型是这样的:@Entity@Table(name="user")publicclassUser{@Id@GeneratedValue(strategy=GenerationType.AUTO)privateLongid;@Column(name="email")privateStringemail;@Column(name="weblink")privateStringwebLink;//getter&setter}我们通过http请求收集表单或移动数据,springmvc会将这些数据提供给Model类用户。例如,我有一个这样的请求:http://localhost:8080/u

spring - 如何在 Spring Data JPA 中使用带有分页的投影接口(interface)?

我正在尝试使用spring数据的新功能projections获取部分实体(NetworkSimple)的页面我已经检查了文档,如果我只要求:CollectionfindAllProjectedBy();它可以工作,但如果我使用的是可分页的:PagefindAllProjectedBy(Pageablepageable);它会抛出一个错误:org.hibernate.jpa.criteria.expression.function.AggregationFunction$COUNTcannotbecasttoorg.hibernate.jpa.criteria.expression.Co

spring - 使用 Spring Boot 框架对基于 Spring JPA 的 DAO 进行分层的正确方法

刚接触SpringBoot和JPA...假设我有两个实体映射到连接到数据库中的两个表。学生1-----另外,假设数据库已经创建并填充。这描述了一个学生有很多类(class)......我的学生实体:@EntitypublicclassStudent{@OneToMany(mappedBy="student")privateListcourses;@Id@GeneratedValue(strategy=GenerationType.AUTO)@Column(name="Student_Id")privatelongstudentId;@Column(name="Student_Name"

spring - 如何将 StatelessSession 与 Spring Data JPA 和 Hibernate 一起使用?

我在Hibernate中使用Spring+SpringDataJPA,我需要执行一些大型且昂贵的数据库操作。我如何使用StatelessSession来执行这些操作? 最佳答案 一种解决方案是实现一个Spring工厂bean来创建这个StatelessSession并将其注入(inject)到您的自定义存储库实现中:publicclassMyRepositoryImplimplementsMyRepositoryCustom{@AutowiredprivateStatelessSessionstatelessSession;@Ove

java - 具有多个 SELECT NEW 语句的 jpa 构造函数表达式

有没有办法拥有多个SELECTNEWjpql中的语句查询(hibernate)?这对我有用:@Query("SELECTNEWcom.test.project.dto.ItemService(g,s,l,r)"+"FROMItemg,Services,Servicel,Servicer"+"WHEREs.id=g.id"+"ANDs.location=l.name"+"ANDs.serviceType='type'"+"ANDl.serviceType='Location'"+"ANDl.area=r.name"+"ANDr.serviceType='Region'")publicLi

spring - 使用 Spring Data JPA、Hibernate 和多事务管理器 : No bean named 'transactionManager' is defined

编辑:对于可能对此问题感兴趣的人,我会在问题的末尾提供问题分析和相关解决方案。我正在为使用Spring3.2、Hibernate4.1、SpringDataJPA1.3和ApacheCXF2.5(特别是JAX-RS模块)的Web应用程序配置一个模块。我有以下配置(运行良好,为简洁起见省略了详细信息):@Bean(name="entityManagerFactory")publicLocalContainerEntityManagerFactoryBeangetEntityManagerFactory()throwsSQLException{LocalContainerEntityMan

java - 如何检测/建议 Spring Data (JPA) 存储库?

我未能为spring数据jpa存储库提供建议。目标是检测(围绕)特定存储库中的所有非void公共(public)方法,这些方法使用自定义注释(本示例中为ResourceNotFound)进行注释,并在返回值为null时引发异常或空集合。@Repository@ResourceNotFound@Transactional(readOnly=true)publicinterfaceCityRepositoryextendsJpaRepository,JpaSpecificationExecutor{…}以下建议是连接使用@ResourceNotFound注释的接口(interface)实现

java - 为什么没有使用 Spring Data JPA 设置版本属性?

想知道SpringDataREST中的@Version注释是如何用于ETags的,但由于某种原因我没有看到ETags填充@Entity@EntityListeners(AuditingEntityListener.class)publicclassVenueimplementsSerializable{privatestaticfinallongserialVersionUID=-5516160437873476233L;privateLongid;...//otherpropertiesprivateLongversion;privateDatelastModifiedDate;//