Questions tagged [spring-data]

0

votes
2

answer
21

Views

JPA: How to map only one property from another entity

Let's say I have two entities: @Entity public class Phone { @Id private Long id; private String number; } @Entity public class Person { @Id private Long id; private String name; } The relationship between a person and a phone is one to one. How could I access only the phone's number in the Person en...
Fabian Mendez
1

votes
1

answer
684

Views

Test Spring Data Repository in a project without a Spring Boot Application main class

I have a small project that does not contain a class to run a Spring Boot Application. In that class I only have some configuration and some repositories. I would like to test those repositories inside the small project. For that, I have the following: @SpringBootTest @DataJpaTest public class TaskR...
Manuelarte
1

votes
3

answer
185

Views

How to insert 780k records Spring Data Postgres

CSV file will be uploaded in Amazon S3 bucket. Current Implementation: Reading CSV file using OpenCSV utility's readAll which returns List Map every column value to an entity object Create a List object (Current Size :: 15000) Invoke Spring Data CRUD Repository saveAll(List objects) Out of 780k reco...
Phaneendra
1

votes
1

answer
1.3k

Views

Spring Data JPA method query with paging gives me an error

I am developing with Spring Data Jpa. I have an interface extending JpaRepository, and I want to query with Query Method and paging. I want to query 'select * from cheat where vote
PLAYMAKER
1

votes
1

answer
576

Views

Spring boot 2.0.3.RELEASE, Spring data rest, application error, failed to start

Unable to start spring boot application. Repository and its associated domain import com.vircosolutions.mobileapi.domain.Awards; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(exported...
Rana Rashid
1

votes
1

answer
53

Views

Spring boot: error asking to implement all methods in JpaRepository

Why is this happening? It didn't happen when I worked on a spring project in STS few months back. I have imported the following in the class: import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; Following is my pom.xml: 4.0.0 org.springframe...
S.K.
1

votes
1

answer
35

Views

Does Spring Data JPA have any way to sum an entity column using method name resolving?

Spring Data JPA can sum colomn using specifications. But does it have any way to sum an entity column using method name resolving? Let's say I want a method sumCreditAmount to sum column with specific name, just like a method findByCreditAmount to fetch all entities with a specific creditAmount.
Riadh
1

votes
2

answer
56

Views

cannot save a document to couchbase using reactive approach

I am trying to persist some date generated by a scheduler and then read them through a rest endpoint in a stream manner. I have a very simple model, a Feed holding only uuid and some text. I also have a repository that extends ReactiveCouchbaseRepository. Persisting works when I use the CouchbaseR...
mooor
1

votes
1

answer
57

Views

Spring data, find by property of a nested object

I have the following code: @Entity public class StudentEntity { @Id private String id; private Student student; ... } public class Student { private String name; private List grades; } public class Grade { private String className; private String grade; } I've set up a spring data mongodb repository...
DraegerMTN
1

votes
2

answer
43

Views

How to programmatically discover the JPA implementation and SQL dialect being used by Spring Boot?

I know it is possible to change the JPA implementation in use by Spring Boot, the default is to use Hibernate, but it's also possible to user others, like EclipseLink. It is possible to find, at application runtime, which JPA implementation is being used, and also discover which SQL dialect is curre...
André Shevantes
1

votes
2

answer
36

Views

How to enable H2 Database Server Mode in Spring Boot

I'm using a H2 database with a file using Spring Boot. In my application.properties, I have this entry: spring.datasource.url=jdbc:h2:file:c:/Testprojekte/spring-boot-h2-db But now I would like to be able to look at the database while running the application, which currently isn't possible because I...
user1119859
0

votes
0

answer
13

Views

Spring Data Rest with url of format /foo/{id}/bar

To conform to our internal standards, we have URLs that take the format /RESOURCE/{id}/COMPONENT trying to do something like @RestResource(path = '/RESOURCE/{id}/COMPONENT') public Optional findById(long id); doesn't work (it does accept requests at /RESOURCE/{ID} though). Is there a way to make thi...
Don Hosek
0

votes
0

answer
12

Views

Spring Data JPA BigList insert

I've been trying for two days now to store an array list with about six million entries in my Postgres database with Spring-Data-JPA. The whole thing works, but it's very slow. I need about 27 minutes for everything. I've already played around with the batch size, but that didn't bring much succes...
StitZle
1

votes
3

answer
106

Views

SQL Error: 23503, SQLState: 23503 in SpringBoot 2.1.4.RELEASE app

I have a SpringBoot 2.1.4.RELEASE RESTful Web Service app., using Spring Initializer, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file. I have this class: @Entity @Table(name='t_menu_alert_notification') public class MenuAlertNotification implements Serializable { /*...
carles xuriguera
1

votes
1

answer
721

Views

Query creation method gives error

My Entity has a field like @Column(name = 'workflow_status', columnDefinition = 'nvarchar(255)') private String workflow_status; So in my Controller I want to fetch the entries by workflow_status, I wrote the Query method that JPA provides List findByWorkflow_status(String workflow_status); But thi...
TweaknFreak
1

votes
2

answer
2.2k

Views

How to use Spring security without password encoding?

I'm trying to learn Spring security currently. I used BCryptPasswordEncoder to encode user password before persisting into a database Code: @Override public void saveUser(User user) { user.setPassword(bCryptPasswordEncoder.encode(user.getPassword())); user.setActive(1); Role userRole = roleRepositor...
Arjun
1

votes
2

answer
1k

Views

Trouble when changing Spring Boot version from 2.0.3.RELEASE to 2.1.0.M4

I have a working code that stops to work when I change Spring Boot version from 2.0.3.RELEASE to 2.1.0.M4 The error is: Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. *************************** APPLICATION FAILED TO START *********...
Mudassir Shahzad
1

votes
2

answer
44

Views

Spring data jpa @Query - Cannot create an “AS” alias for a result map

I map the result of the following JPQL-Query directly to a SpecialCustomDto object instead of the used javax.persistency entity object MyEntity. But I do not know, how to access the COUNT(DISTINCT e.attributeB), which will be mapped to the SpecialCustomDto. This is the query. @Repository public inte...
git-flo
1

votes
2

answer
69

Views

How to filter null values in ArrayList

I have a very big code. I faced an issue where at very starting of code, null gets inserted inside arraylist custlist i.e custlist looks like [null]. And after many lines of code, I had my code changes where I was building up Predicate using custlist as shown below: CriteriaBuilder cb = entityManag...
ASharma7
0

votes
0

answer
3

Views

How can I (if I can) extend a composed repository?

I am trying to give a Generic Parrent repository to all my 'per aggregate root' repositories which I can later use polymorphically. I have composed a parent 'composed repository'. Which is to be implemented by other specific Repositories. @Repository public interface ZoneNameJpaRepository extends Ge...
Aditya Kumar
1

votes
2

answer
930

Views

Getting MongoDB current collection name

I am using mongoDB + Java+SpringData. Is it possible to get current collection, without it's name? Thanks!
EK.
1

votes
1

answer
451

Views

How are ids autogenerated in spring data couchbase?

I want to create autogeneration of IDs to my documents in spring data couchbase. Spring docs has steps for this: https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.autokeygeneration Here is my code: @Document public class User { @Id @GeneratedValue(strategy = Gener...
User1230321
1

votes
1

answer
180

Views

Jackson One-to-many Many-to-One infinite Loop deserialization errors

I have 2 models - Member.java @Entity @Table(name='members') public class Member { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name='member_id') private Integer id; @Column(name='member_name') @NotNull private String name; @Column(name='member_joining_date') @NotNull private Date joi...
Prateek Narendra
1

votes
0

answer
49

Views

javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: void

I am getting following Exception: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: void while calling spring data jpa repository's save method, any specific reason behind this ? *Edited please see activitymaster and repository I have added. @Entity @Table(nam...
Mayur
1

votes
1

answer
37

Views

Spring Data JPA to deep and weird mapping

Lately I'm trying to create CRUD with many-to-one and one-to-many. I'm having following weird results, and I can't deal with it. Here's the JSON from /teams, what I've got [ { 'id': 3, 'name': 'team1', 'footballers': [ { 'id': 12, 'name': 'karol', 'age': 0, 'team': { 'id': 3, 'name': 'team1', 'footb...
iwannabeprogrammer
1

votes
1

answer
501

Views

Spring Data JPA - findAllBy query checks for null?

The documentation shows that findByLastnameAndFirstname equals to where x.lastname = ?1 and x.firstname = ?2. We know that in sql = NULL is always false. You have to use IS NULL. Let's say we have an entry firstname = 'First' and lastname IS NULL. I call this findByLastnameAndFirstname(null, 'First'...
Shawn
1

votes
1

answer
465

Views

Creating Query using Date parameters with Spring Jpa Repository

I want to execute a query via JpaRepository that uses Date objects as parameters (java.util.Date). However, each time the method from the repository is called, it returns a null value. When I pass Integer values and work with id instead of Date I don't get any errors and the query is successfully ex...
Josip Mrđen
1

votes
0

answer
123

Views

cascade persist results in null column value for a ManyToMany entity

Owner: @Entity public class Strategy implements Serializable { @Id @GeneratedValue private Long id; @ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST}) @JoinTable(name = 'StrategyHost', joinColumns = {@JoinColumn(name = 'strategyId')}, inverseJoinColumns = {@JoinColumn(name = 'host...
Tiina
1

votes
2

answer
861

Views

Filter JPA repository by multiple optional parameters

I have a simple REST service that returns user profile entity that has about 20 fields. I need to implement a functionality to filter the data where last name is required but all other fields (first name, age, city, state, zip, etc. ) are optional. Is there a way to do it using JpaRepository without...
rma
1

votes
0

answer
50

Views

How to write this aggregation query in spring data mongoDB

How to implement this query in spring data mongoDB using MongoTemplate find number of suggestions in a document with particular id. Query: b.node.aggregate( { $match: {'id':'a'} }, { $project: { count: { $size:'$sugg' }, '_id':0 } } ) Schema: { 'id':'a', 'sugg':[ { 'w':'a', 'f':1 }, { 'w':'b', 'f':1...
Amit Bansal
1

votes
0

answer
1.3k

Views

2 Hikari CPs with different datasource configurations?

Has anyone successfully configured two hikari connection pools with different datasources in a spring boot application? How do I do it using application.properties?
ramkris
1

votes
1

answer
124

Views

spring data mongodb embeded query

{ '_id' : '7959305563', '_class' : 'com.loylty.messagingEngine.entities.message.GroupIdDeliveryStatusReport', 'DATA_LIST' : [ { '_id' : '7959305562-1', 'mobile' : '9566337867', 'status' : 'DELIVRD', 'senttime' : '2018-01-09 14:19:42', 'dlrtime' : '2018-01-09 14:57:06', 'custom' : '9566337867' }, {...
Muddassir Rahman
1

votes
1

answer
47

Views

spring data - get beans in a custom default repository implementation

Im trying to upgrade my project from spring-boot-1.4.3.RELEASE to spring-boot-1.5.9.RELEASE. In the 1.4.3.RELEASE the way I have used my custom implementation of repositories is as follow: Made an interface MyCustomRepositroy that extends JpaRepository Had a class MyCustomRepositoryImpl that impleme...
Guy Smorodinsky
1

votes
0

answer
213

Views

How to disable AuditEntityListener (Spring Data) temporary?

We use Spring Data with die AuditEntityListener to update the change-user and the changedate. But for our migration (Spring Batch) of old data we need to set the create-user and the change-user manualy, but we cannot disable the functionality of the AuditEntityListener. We also use envers in some en...
grueny
1

votes
1

answer
354

Views

Not all Spring JPA and datasource properties working in console application

Trying to configure JPA datasource in my java console app, which uses spring-data-jpa and mysql, and it seems not all defined properties are worked: application.properties spring.datasource.url=jdbc:mysql://xyz:3306/xyz spring.datasource.username=xyz spring.datasource.password=xyz spring.jpa.propert...
Viktor V.
1

votes
1

answer
205

Views

SpEL are not read in @Query after Spring Boot 2.0.0 M7 update

I had my Spring Boot 2.0.0 M3 application developed. Everything worked just fine. But after updating to Spring Boot 2.0.0 M7 (or even to Spring Boot 2.0.0 M5 more recently) SpELs in my @Query are not longer compiled properly. For example @Query('SELECT m FROM com.mypackage.models.Model m WHERE m.st...
Serg Vasylchak
1

votes
1

answer
762

Views

mongodb criteria query for primary key _id?

I write the criteria query like this query.addCriteria(Criteria.where('_id').is(id)); but the result is {'_id':123456789123450} which is not searching result. What I need to change to search the result using the criteria query on _id?
Prabhat Yadav
1

votes
3

answer
937

Views

Disable Spring Boot HibernateJpaAutoConfiguration but still getting a related error

@SpringBootApplication(exclude = { HibernateJpaAutoConfiguration.class, JndiConnectionFactoryAutoConfiguration.class, XADataSourceAutoConfiguration.class, JndiDataSourceAutoConfiguration.class, ...) like code above, I disable pretty much Auto Configuration Classes provided by Spring Boot, because I...
EthanZhang
1

votes
1

answer
322

Views

Delete resource in spring data rest hateoas with relationship

I have a category, item and roles for a restaurant. I can GET and POST request using postman but when I try to delete an entry in 'category' it gives a 204 - no content but the data is still not being deleted. is this because the category has a many to one relationship with the restaurant. on the ot...
shankara narayanan
1

votes
1

answer
118

Views

Get elastic search query from spring data Jpa

In my code base, I have two code for search on elastic. One is through ElasticSearchTemplte from there I build the elastic query and query on elastic. In the second one, I am querying through spring-data-jpa. In the first case, I can see my elastic search query and can directly query on ES. My quest...
Ravat Tailor

View additional questions