problem about spring-data-jpa-Collection of common programming errors


  • Sitansu
    java spring spring-data-jpa spring-boot
    Why does the addition of @EnableAutoConfiguration to the following spring-boot app cause it to not create an entityManagerFactory? If I remove @EnableAutoConfiguration everything works fine. Can anyone shed light on this behaviour?package test.builder;import javax.sql.DataSource;import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; im

  • CFL_Jeff
    java hibernate inheritance jpa spring-data-jpa
    Consider the following hierarchy, where entities WidgetA and WidgetB extend an abstract Widget superclass:@Entity @Inheritance(strategy = InheritanceType.JOINED) public abstract class Widget implements Serializable {@Column(name=”serialNumber”, length=64, nullable=false, unique=true)private String serialNumber;…and@Entity public class WidgetA extends Widget implements Serializable { …and@Entity public class WidgetB extends Widget implements Serializable { …I need to search for Widgets b

  • Leonard Brünings
    spring hibernate spring-data-jpa spring-transactions
    In our Tests we see this mysterious StackOverflowError in our logs. Our tests still complete normally, but I’d still like to fix it if possible. Any ideas what is causing this infinite recursion and how to fix it?13569 [main] DEBUG org.hibernate.SQL – select sequence_next_hi_value from hibernate_sequences where sequence_name = ‘IDS’ for update Hibernate: select sequence_next_hi_value from hibernate_sequences where sequence_name = ‘IDS’ for update 13570 [main] DEBUG org.hibernate.SQL – insert i

  • balteo
    spring hibernate jpa spring-data-jpa
    I have an issue with a Spring controller method. It actually does two updates on the same entity which causes the StaleObjectStateException. The problem is that when I retrieve the Member instance, I think it somehow causes an update (see //UPDATE ONE) of the Advertisement instances (this is not wanted actually) and when I update the Advertisement instance (see //UPDATE TWO), then it throws a StaleObjectStateException.My question is how can I prevent this exception from occurring in my case (bea

  • user1555190
    spring jpa-2.0 spring-data-jpa
    I have query as such :@Query(“select a from Ability a where a.eventLogic = ?1 AND a.abilitySetId = ?2 ORDER BY RAND() LIMIT ?3”)BUt i get an error:Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: LIMIT near line 1, column 117How can i programmatically put in the limit number?

  • Mariusz
    hibernate jpa spring-data-jpa
    I use JPA with hibernate. I want to check that row with specified name and username exists. The following query raises an error:@Query(“select exists (select 1 from Strategy s where s.name=:name and s.username=:username)”) Boolean exists2(@Param(“name”) String name,@Param(“username”) String username);Error:Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [select exists (select s from com.soft.domain.strategy.Strategy s where s.name=:name and s.username=:username)]

  • dhroove
    java hibernate exception jpa-2.0 spring-data-jpa
    I don’t know if this approach is the best or not. But I have a requirement where I need to handle Spring JPA repository (DAO layer) exception. Handle in the sense may be propogate it to UI or may be do some logic on service layer.Now as per present scenario from over repositories all our SQL Exception got wrapped into Runtime exception DataAccessException.Now one way if I want to propogate this Exceptions to my UI layer than I catch this Runtime Exception on Service layer and wrap this exception

  • chrylis
    java spring configuration annotations spring-data-jpa
    I’ve got the spring configuration class:@Configuration @EnableJpaRepositories InfrastructureContextConfiguration@Beanpublic LocalContainerEntityManagerFactoryBean entityManagerFactory() {…}I wish to set the entityManagerFactoryRef attribute of the @EnableJpaRepositories with entityManagerFactory().getObject() invocation. Can I do that and how if it is allowed?

  • Matt Whipple
    spring-data-jpa
    I’m presently struggling with getting Spring Data JPA Auditing to work, it is presently not setting the fields and doesn’t seem to be getting called in any way when working with Entities. In particular any insight into how it hooks into the standard flow of persisting Entities would be helpful.I’m presently using Spring Data JPA 1.5.0.M1 with Spring 3.2.6 and the basic configuration for the auditing piece is:@Configuration @EnableJpaAuditing(auditorAwareRef = “auditorAware”) @EnableJpaRepositor

  • balteo
    jpa spring-roo spring-data spring-data-jpa
    I use Spring Roo + Spring Data + QueryDSL and I have the following classes/interfaces:public interface FamilyAdvertisementRepositoryCustom { }@RooJpaRepository(domainType = FamilyAdvertisement.class) public interface FamilyAdvertisementRepository extends FamilyAdvertisementRepositoryCustom { }public class FamilyAdvertisementRepositoryImpl extends QueryDslRepositorySupport implements FamilyAdvertisementRepositoryCustom {//NO CONSTRUCTOR }all in following package: com.bignibou.repository;With foll

  • chrisjleu
    java spring jpa spring-data-jpa
    Another question for my EclipseLink and Spring (MVC and spring-data) version 3.1.1 set-up:I’m trying to get JPA working without the use of the persistence.xml file in accordance with this article. In the article it says:Usually, JPA defines a persistence unit through theMETA-INF/persistence.xml file. Starting with Spring 3.1, this XML fileis no longer necessary – the LocalContainerEntityManagerFactoryBeannow supports a ‘packagesToScan’ property where the packages to scanfor @Entity classes can b

  • Quantum
    spring transactions openjpa spring-data-jpa atomikos
    I am using Spring Data JPA (SDJ) and during my integration tests, I’ve come across a weird situation – I’ve probably misconfigured something, but I fail to see what that might be.In a nutshell – it would seem that SDJ simply fails to invoke an implementation of Spring’s PlatformTransactionManager once there is any kind of method declared on repository interface (i.e., the one that extends JpaRepository<T, ID>). I’ve drilled down this behaviour to a pretty banal reason – in this situation,

  • shelley
    java spring spring-data spring-data-jpa
    In a web application that uses Spring Data JPA with Hibernate, we utilize the web pagination functionality to provide paging and sorting capabilities in various lists of entities.@Controller public class MyEntityController {@RequestMapping(method = RequestMethod.GET)public ModelAndView list(Pageable pageable) { … } }@Configuration public class MyWebMvcConfig extends WebMvcConfigurationSupport {@Overridepublic void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers

  • masi
    java spring annotations spring-data spring-data-jpa
    i followed the tutorial posted here to get a basis application to work with Spring Data JPA. Now, how i understood, using the configuration<jpa:repositories base-package=”my.package.to.scan” />should result in that package beeing scanned by Spring Data JPA for interfaces extending JpaRepository and create a concreate bean of it so it can be used anywhere in my service classes using simple Spring @Autowired. But it fails, saying it can’t find a bean with className (which is the default name

  • Malave
    java groovy jpa-2.0 spring-data spring-data-jpa
    I have an Item and this Item could have any number of categories. I need to do a query to return all the items that correspond to a category. First let me put the domain objects:@Entity class Item {@Id@GeneratedValueLong id;String name@ElementCollection@JoinColumn(name = “security_id”)List<Category> categories = [] }And here is the enum with the categoriespublic enum Category {OFFICE(“office”),HOME(“home”),GARDEN(“garden”)final String value;private Category(String value) {this.value = valu

  • Joachim Sauer
    solr spring-data spring-data-jpa spring-data-solr
    To enable full text search, I ever used hibernate-search and solrJ, No I am trying spring-data-solr, but found I seems not working together with spring-data-jpa. I just can’t make the configuration correct. If I add the following solr configuration xml to my project.I get error message. The config xml file of spring-data-solr is:<?xml version=”1.0″ encoding=”UTF-8″?> <beans xmlns=”http://www.springframework.org/schema/beans” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:p

Web site is in building