spring-data

Update index dynamically doesn't work (Spring Data Elasticsearch)

折月煮酒 提交于 2019-12-24 18:18:49
问题 I have a model which is: @Document(indexName = "index", type = "logs") public class Log { @Id private String id; private String test_no; private String entire_log; private String method; private String timestamp; private String thread_name; private String level; private String logger_name; private String formatted_message; // CONSTRUCTORS, GETTERS AND SETTERS... } I have an applicationContext.xml file which contains a bean, used to save the value of the dynamic index. The location of this

How to use criteria query on refrence collection in mongo db

让人想犯罪 __ 提交于 2019-12-24 17:22:32
问题 How do I find all the person which are having city ="XYZ" in Address collection public class Person { @Id private String id; private String description @DBRef private Address address; // Getters and Setters } public class Address { @Id private String id; private String area private String city // Getters and Setters } 回答1: Mongo understands @DBRef as a reference to another document, in this case, an Address document and ultimately when the object is loaded from MongoDB, those references will

Spring JPA - Delete Child in One-toMany relationship

天涯浪子 提交于 2019-12-24 15:33:24
问题 I have the following Author class: @Entity public class Author implements Serializable{ private static final long serialVersionUID = 1L; @Id @GeneratedValue private Long id; @OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL) @JoinTable( name="author_book", joinColumns = @JoinColumn( name="author_id"), inverseJoinColumns = @JoinColumn( name="book_id") ) private Set<Book> books= new HashSet<Book>(); public Author() { super(); } public Long getId() { return id; } public void setId(Long

Best practice for open/get Hibernate session in Spring 4 + Hibernate 4.3.1.final

。_饼干妹妹 提交于 2019-12-24 15:26:32
问题 In our project we use Spring and Spring Data (for server side API service), but sometimes we do query not using Spring Data, but using JPA criteria. In order to do so we use: @PersistenceContext private EntityManager em; ... CriteriaBuilder cb = em.getCriteriaBuilder(); ... From the Spring docs: Although EntityManagerFactory instances are thread-safe, EntityManager instances are not. The injected JPA EntityManager behaves like an EntityManager fetched from an application server's JNDI

JPQL JOIN Queries

一笑奈何 提交于 2019-12-24 15:19:50
问题 I'm trying to make a very simple JPQL using a join but I'm having zero success. I want to get the most recent log in date of a user, given a user id. I am using Spring Data JPA + Hibernate. I have a MySQL database which contains the table Activity: @Table(name = "activity") @SuppressWarnings("serial") public class Activity implements Serializable { @Id @GeneratedValue private Long id; @Column(name = "date", insertable = true, nullable = false, updatable = false) @Temporal(TemporalType

JPA query equals between two properties

青春壹個敷衍的年華 提交于 2019-12-24 14:57:54
问题 It is possible to compare two properties with JPA custom query ? Registration.java : @Entity public class Registration implements Serializable { @Id @GeneratedValue(generator = "uuid") private UUID uuid; @ManyToOne(targetEntity=Entry.class) private Entry entry; @ManyToMany(targetEntity=Rate.class,fetch = FetchType.EAGER) private List<Rate> rate; @ManyToMany(fetch = FetchType.EAGER) private List<Planning> planning; } Rate.java : @Entity public class Rate implements Serializable { @Id

Cassandra entities must have the @Table, @Persistent or @PrimaryKeyClass Annotation

无人久伴 提交于 2019-12-24 14:04:27
问题 I am working on spring boot application and trying to connect with Data Stax Cassandra. Below is the I have written. package com.sampleProj.dto; import java.io.Serializable; import java.sql.Blob; import java.sql.Timestamp; import org.springframework.data.cassandra.mapping.Column; import org.springframework.data.cassandra.mapping.PrimaryKey; import org.springframework.data.cassandra.mapping.Table; @Table public class Inbound implements Serializable{ @PrimaryKey private int transactionalId;

How do I configure (XML) QueryDSL to be used with Spring Data and Spring MVC?

跟風遠走 提交于 2019-12-24 13:07:27
问题 Quick reference for those looking to configure Spring MVC, Spring Data, and QueryDSL using XML config. 回答1: In pom.xml : <properties> <querydsl.version>3.6.7</querydsl.version> </properties> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.6.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> <version>1.9.0.RELEASE</version> </dependency>

Spring Data JPA - Delete child entities instead of setting to null on update?

删除回忆录丶 提交于 2019-12-24 12:43:27
问题 I have the following domain model users ---- id (PK) name orders ------ id (PK) userid (PK) name Orders.userid references id in User and is part of the composite primary key. (I need userid in the primary key since it is a partition key and in MySQL we cannot create the primary key without the partition key) On using JPA to update User, if I try to clear the associated orders collection using User user = userRepository.getOne(id); user.getOrders().clear(); userRepository.save(user); JPA first

What are the advantages of using Spring Data REST over Spring Data JPA?

僤鯓⒐⒋嵵緔 提交于 2019-12-24 12:10:09
问题 I know that spring data rest will export your repositories as REST services..but i want to know advantages of that over use of spring data jpa. 回答1: This is a fruit-salad-to-buffet comparison as the technologies solve completely different problems: Spring Data JPA eases working with JPA on top of Spring. It exposes a repository programming model which allows you to build Java APIs to access data in relational databases. Spring Data REST builds on top of the repository abstraction (not being