spring-data

indexing document to a specific collection using spring data solr

▼魔方 西西 提交于 2020-01-15 09:04:54
问题 I am trying to index a document to a specific collection in solr. The collection name is 'program'. I am using spring data solr. I am getting the below error when trying to save the document: HTTP ERROR 404 Problem accessing /solr/update. Reason:Not Found My assumption is that the annotation @SolrDocument is not recognized. spring-data-solr is trying to post the document to /solr/update whereas it should try to post it to /solr/program/update.However I am not sure how to prove it or fix it.

@CreatedBy and @LastModifiedBy set actual entity instead of id

ぃ、小莉子 提交于 2020-01-14 22:36:29
问题 I have an entity which looks like: @Audited @Data @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class BaseEntity { public static final long UNSAVED = 0; @Id @GeneratedValue private long id; @CreatedDate @Column(name = "created_at", updatable = false) private ZonedDateTime createdAt; @CreatedBy @OneToOne(fetch = FetchType.EAGER) @JoinColumn(name = "created_by") private User createdBy; @LastModifiedDate private ZonedDateTime updatedAt; @OneToOne(fetch =

@CreatedBy and @LastModifiedBy set actual entity instead of id

佐手、 提交于 2020-01-14 22:34:31
问题 I have an entity which looks like: @Audited @Data @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class BaseEntity { public static final long UNSAVED = 0; @Id @GeneratedValue private long id; @CreatedDate @Column(name = "created_at", updatable = false) private ZonedDateTime createdAt; @CreatedBy @OneToOne(fetch = FetchType.EAGER) @JoinColumn(name = "created_by") private User createdBy; @LastModifiedDate private ZonedDateTime updatedAt; @OneToOne(fetch =

How to handle compound keys with Spring Data JDBC

谁都会走 提交于 2020-01-14 14:44:08
问题 I'm trying to use Spring Data JDBC to access a table that has a compound key, and although I can find lots of info on how Spring Data JPA handles this, the same doesn't seem to apply to Spring Data JDBC. Can anyone give a quick example of how you need to declare an Entity/Repository with Spring Data JDBC to talk to a table with a compound primary key ? (Eg. Two Strings) 回答1: Using the CrudRepository for compound keys is currently (Version 1.0.2) not possible. Of course, you can still use

Set transient value from database with Spring Data JPA

旧城冷巷雨未停 提交于 2020-01-14 13:51:30
问题 I wonder if there is a way to retrieve a generated value from database as an extra column and map it to a transient value. I'll try to explain myself, I wish something like this: @Entity @Table(name = "thing") public class Thing { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "itemid") private Long itemId; private String someValue; @Transient private double distance; // constructors, getters, setters, etc.. (include transient methods) } Repository("thingRepository")

Set transient value from database with Spring Data JPA

你说的曾经没有我的故事 提交于 2020-01-14 13:51:15
问题 I wonder if there is a way to retrieve a generated value from database as an extra column and map it to a transient value. I'll try to explain myself, I wish something like this: @Entity @Table(name = "thing") public class Thing { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "itemid") private Long itemId; private String someValue; @Transient private double distance; // constructors, getters, setters, etc.. (include transient methods) } Repository("thingRepository")

Does Spring Data support Elasticsearch 5.x?

帅比萌擦擦* 提交于 2020-01-14 09:52:26
问题 Does the latest version of Spring Data (2.1.0.RELEASE or 3.0.0M1) support Elasticsearch 5.x? If not, When will it support it? There is no information about this in their docs: Spring Data Elasticsearch 回答1: Not support yet, you can try ES native java api. 回答2: Yes, now spring-data supports Elasticsearch v5.x. It's not supported with RELEASE version, it's supported with BUILD-SNAPSHOT version. To use it, you have to add repository URL as well. For maven project, build script will look

Is there any Spring Annotation to Set Default value for a Field (Mongo)?

牧云@^-^@ 提交于 2020-01-14 09:49:07
问题 Is there any Spring Annotation to Set Default value for a Field (Mongo) ? 回答1: No need for spring annotations, this should do the trick: import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; @Document public class Doc { @Field private String field = "CustomDefaultValue"; } 来源: https://stackoverflow.com/questions/41344173/is-there-any-spring-annotation-to-set-default-value-for-a-field-mongo

Does Spring Data MongoDB support enums?

徘徊边缘 提交于 2020-01-14 07:17:06
问题 For Java enum type, I learn that there are two solutions for MongoDB: serialization and using Jackson’s ObjectMapper. Can the MongoRepository work with an enum data type with either of those approaches or I have to write a customized repository? 回答1: Yes, Spring Data MongoDB supports enums. Just use them in your domain model. 回答2: Spring Data Mongodb can serialize enum into string using enum's name as value. Let's say, it uses the second approach from the article http://www.vineetmanohar.com

Return more data than model contains using Spring Data

佐手、 提交于 2020-01-14 04:31:16
问题 I'm working with Spring Data which is great stuff, but sometimes I need to get more data from database than my model can handle. For example I have model like below. @Entity @Table(name = "email") public class Mail implements Serializable { @Getter @Setter @GeneratedValue(strategy = GenerationType.IDENTITY) @Id private Long id; @Getter @Setter private String text; } An I my query will be more complex than usual. I want to get my model and in addition number of similar entities, using group by