Tag: spring data jpa

JHipster按其实体的字段搜索实体

我有锦标赛实体。 他与Prize实体有OneToOne关系。 奖品实体已提交“金额”。 因此,如果我想要搜索具有2个值之间的奖项的锦标赛,我该如何使用JHipster QueryService?

Spring Dependency Injection入JPA实体监听器

我需要将一个Springdependency injection到JPA实体监听器中。 我知道我可以使用@Configurable和Spring的AspectJ weaver作为javaagent解决这个问题,但这似乎是一个hacky解决方案。 有没有其他方法可以完成我想要做的事情?

启动Spring应用程序时出错:bean的初始化失败; 嵌套exception是AbstractMethodError

我有一个使用Spring MVC,Spring Security和Spring Data的Spring应用程序。 一切都过去完美无缺,直到我将Spring Data的版本从1.9.0.RELEASE更新为1.9.0.RELEASE 这是无法创建的存储库bean(BeanCreationException): @Repository // Enables exception translation public interface UsuarioRepository extends CrudRepository { @Query(“SELECT u FROM Usuario u WHERE LOWER(u.login) = LOWER(:login)”) Usuario findByLogin(@Param(“login”) String login); @Query(value = “SELECT * FROM Usuario WHERE fl_ativo = true”, nativeQuery = true) Iterable findAllActives(); } 这是pom.xml (Maven): 4.0.0 br.com.nooder portal-jstl 0.0.1-SNAPSHOT war 2.8.2 […]

spring数据动态地组成@query查询

我有一种情况,我必须在某些方法中@Query JPQL查询,然后将此查询传递给spring数据查询方法,以用作@Query注释中的查询 @Query(value = “:DyanamicQuery”) List filterConfigurPrizeInsurance(String DyanamicQuery); 或者至少是条件部分 @Query(value = “SELECT c FROM PrizeInsuranceConfiguration c WHERE :DyanamicConditions”) List filterConfigurPrizeInsurance(String DyanamicConditions);

Spring Data配置 – 找不到hibernate.properties

我尝试使用Hibernate内存数据库配置Spring Data,基于此 , 这个答案如下: 但我一遍又一遍地得到: org.hibernate.cfg.Environment中。 HHH000206:找不到hibernate.properties 问题是我不想在properties文件中指定它,因为我以前没有Spring Data我想在xml配置中设置它,就像我基于的答案一样。 我错过了什么吗? 提前感谢您的帮助。

数据JPA。 按示例查询。 无法使用Long值进行搜索

我有一个实体产品 @Entity @Table(name = “Products”) public class ProductEntity implements Serializable{ @Id @GenericGenerator(name = “generator”, strategy = “increment”) @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @Column(name = “model”, nullable = false) private String model; //setters and getters } 在这里我是如何尝试通过示例查询: ProductEntity product = new ProductEntity(); product.setId(productId); Example ex = Example.of(product); Page pages = productRepository.findAll(ex, page); 但我得到PostgreSQL错误:PSQLException:错误:语法错误在“L”或接近“L”。 这是创建的查询: Hibernate: select productent0_.id […]

Spring:获取ManyToOne实体时,引用实体(OneToMany)未显示在JSON中

当我在POSTMAN中发送GET请求以获取我的所有子实体(Town)时,父实体(省)未显示在JSON响应中。 这是我的控制器。 @RequestMapping(value =”api/v1/town”,method = RequestMethod.GET) public ResponseEntity<List> getAllTowns() { List towns = townService.getAllTowns(); if(towns.isEmpty()) { return new ResponseEntity<List>(HttpStatus.NO_CONTENT); } return new ResponseEntity<List>(towns, HttpStatus.OK); } 这些是我的实体。 家长class @Entity @Table(name = “PROVINCE”) public class Province { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = “PROVINCE_ID”) private long id; private String name; @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy […]

自定义存储库基类+ QueryDslPredicateExecutor

我发现QueryDslPredicateExecutor对于减少样板非常有用,但它似乎正在投入一个猴子扳手。 我现在正在尝试使用自定义基类存储库扩展JpaRepository ,并且在启动时,Spring无法正确实例化存储库。 //Custom base class @NoRepositoryBean public interface IdAwareRepository extends JpaRepository { // ID getId(A a); } // Base class implementation public class IdAwareRepositoryImpl extends SimpleJpaRepository implements IdAwareRepository { public IdAwareRepositoryImpl(JpaEntityInformation entityInformation, EntityManager entityManager) { super(entityInformation, entityManager); } } // Individual repo @Repository public interface MyPojoRepository extends JpaRepository, QueryDslPredicateExecutor { } // Spring boot […]

Spring CrudRepository在自定义查询方法定义上抛出AbstractMethodError

我正在尝试在扩展CrudRepository接口的接口中创建自定义查询。 不幸的是,每次收到java.lang.AbstractMethodError时都会出于某些原因。 请参阅下面的完整堆栈跟踪。 据我所知,问题是Spring框架应该“神奇地”为我的方法声明创建一个实现,但由于某种原因它没有成功。 存储库界面: public interface PresentationRepository extends CrudRepository { Iterable findAll(Sort sort); Page findAll(Pageable pageable); List findByTitle(String title); // the problematic line } 演示实体课程: @Entity @Table(name = “presentation”) public class Presentation { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = “presentation_id”) Integer id; String title; String logo; @Column(name = “length”) Integer interval; @Column(name = “pages”) […]

crudrepository findBy元组列表的方法签名

我有一个像这样的实体类: @Entity @Table(name = “CUSTOMER”) class Customer{ @Id @Column(name = “Id”) Long id; @Column(name = “EMAIL_ID”) String emailId; @Column(name = “MOBILE”) String mobile; } 如何使用crudrepository spring data jpa为下面的查询编写findBy方法? select * from customer where (email, mobile) IN ((“a@bc”,”8971″), (“e@fg”, “8888”)) 我期待着类似的东西 List findByEmailMobileIn(List tuples); 我想从给定的对中获取客户列表