spring-data

Can I use Spring Data JPA Auditing without the orm.xml file (using JavaConfig instead)?

倖福魔咒の 提交于 2019-12-29 06:41:11
问题 I'm trying to get Spring Data Auditing to work in my Spring 3.2.8 / Spring Data 1.5 / Hibernate 4 project. As per the Spring Data Auditing docs, I've added the @CreatedBy , etc annotations to my entities, created by AuditorAware implementation, and instantiated it from within my JavaConfig. However, it never seems to fire. I find the docs a little confusing. It appears that the JavaConfig entry replaces the xml entry, but I am not sure. I don't currently have any orm.xml file in my

Difference between @RestController and @RepositoryRestController

醉酒当歌 提交于 2019-12-29 05:47:45
问题 What is the typical use case code that shows the difference between those two annotations - meaning the @RestController and the @RepositoryRestController - ? 回答1: According to the annotation the RepositoryRestController is a way to provide custom controllers that still take advantage of spring data rest functionality http://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.overriding-sdr-response-handlers Sometimes you may want to write a custom handler for a

GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement

允我心安 提交于 2019-12-29 05:19:29
问题 I am a novice in hibernate world and facing, WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement exception while I run my stand-alone programe in hibernate 5.2.9 version. But in hibernate 4 version all my code runs well. I looked for many questions and solve but not working answer i got. Configuration file hibernate.cfg.xml <hibernate

How to compare two strings in mongoDB spring data?

六月ゝ 毕业季﹏ 提交于 2019-12-29 02:12:10
问题 i'm trying to compare two string in mongoDB spring Data. My Code: @GET @Path("/reqvolatility") @Produces(MediaType.APPLICATION_JSON) public long getReqVolatility() throws JsonParseException, JsonMappingException, IOException{ String query = "{},{_id:0,levelId:1,reqID:1,creationTime:1,lastModified:1}"; Query query1 = new BasicQuery(query); query1.addCriteria(Criteria.where("creationTime").ne("lastModified")); long reqvolatility = getMongoOperation().count(query1,RequirmentVO.class); return

No qualifying bean of type 'java.lang.Class<org.springframework.data.repository.Repository<?, ?>>'

 ̄綄美尐妖づ 提交于 2019-12-25 18:41:18
问题 Application depends on a number of spring data projects including Neo4j, Solr and Jpa. I recently had to update spring-data-solr to Snapshot-3.0.0.M1 (to eliminate another dependency conflict). I think one of the transitive dependency is causing a conflict with neo4j. If I remove spring-neo4j from project, error (see below) seem to go away. I have a attached a sample project that recreates the issue. Run Test Class AccountServiceJpaTester.testSaveAccount() Download sample project from here

Spring Data using sort not at the end

为君一笑 提交于 2019-12-25 17:45:13
问题 Can I give sort parameter not at the end expresion? Because i need use sort parameter inside over() function. example: @Query(value = "...?2...over(?4)...?1...?3") myMethod(int a,int b,int c,Sort sort); or expression for sort inside over: ,--#sort\n , #{#sort} .. I still get : java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.lang.Integer ...name of method.. (int,int,int,org.springframework.data.domain.Sort)! 回答1: Parameters of type Sort get

How can I use a custom ID conversion with DomainClassConverter?

风格不统一 提交于 2019-12-25 11:47:32
问题 I have a SQL database where primary keys are UUIDs, but the canonical string representation of a UUID is very long, and I would like to use a shortened version (Base58) in my URLs. Spring Data's DomainClassConverter will convert MVC request parameters or path variables into domain objects, but I want to be able to modify the resolved ID before it's passed to the repository. The default SpringDataWebConfiguration creates a DomainClassConverter using a FormattingConversionService supplied by

Java Criteria API join self referencing entity

眉间皱痕 提交于 2019-12-25 11:28:08
问题 I'm trying to do a nested join on a self referencing entity, please bear with me, it will make sense :) Thing.java class Thing { Integer something; Person owner; } Person.java class Person { String name; Person parent; } Note: A Person with parent=null means that they are a parent, and cannot have a parent. It's an alien world! :P Query: Root<Thing> root = query.from(Thing.class); Join<Thing, Person> ownerJoin = root.join(Thing_.owner); Join<Person, Person> parentJoin = ownerJoin.join(Person_

Java Criteria API join self referencing entity

自古美人都是妖i 提交于 2019-12-25 11:27:04
问题 I'm trying to do a nested join on a self referencing entity, please bear with me, it will make sense :) Thing.java class Thing { Integer something; Person owner; } Person.java class Person { String name; Person parent; } Note: A Person with parent=null means that they are a parent, and cannot have a parent. It's an alien world! :P Query: Root<Thing> root = query.from(Thing.class); Join<Thing, Person> ownerJoin = root.join(Thing_.owner); Join<Person, Person> parentJoin = ownerJoin.join(Person_

Persisting objects containing primitive arrays with spring-data-mongodb

試著忘記壹切 提交于 2019-12-25 10:18:23
问题 I'm using spring-data-mongodb version 1.1.1.RELEASE . I am able to persist an object if all the member variables are primitive types, even if the names of the @PersistenceConstructor arguments don't match exactly the names of the member variables by using the @Field("foo") and @Value("#root.foo") annotations. However, I get a MappingInstantiationException (Illegal arguments for constructor) when I try to persist objects that contain primitive arrays. This holds true regardless of whether the