My situation is this: I am creating a marketplace where users can buy and sell products. I am trying to list a product with a ManyToOne relationship with the logged in user. I am getting the error: Field ‘user_id’ doesn’t have a default value. Im guessing this is because I haven’t set …
Tag: spring-data
Springdata Elasticsearch Auditing LocalDateTime conversion exception
I am using Springdata elasticsearch version 4.4.3. I have configured ElasticSearch Auditing and created and Abstract Entity (Document) which is extended by every each entity. I am getting an exception because of convertion from Java LocalDateTime in elasticseach database when I try to create a document. Here …
Spring boot “no transaction is in progress” with 2 datasources
I have two databases and i’m trying to save some records to both of them inside a service method. This gives me the error: org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in p…
How to automatically generate id in sequence in spring jpa?
I need to make a one-to-many sequence as follows: for example: category sub category 1 1 1 2 2 1 2 2 2 3 3 1 Data model: enter image description here Java code/Mapping: Category class SubCategory class With the code above, I’m getting the following result: category sub category 1 1 1 2 2 3 2 4 2 5
Spring implements to kinds of Repository interface
I’m trying to study Spring more specific Spring Data but i have a question about the use of interface Repository and its derivatives classes and i asking you help for clarify them. For example i see this code example extends CrudRepository but i see the using of extends keyword but no implements. why ? …
Does JPQL support the use of a boolean result in another expression?
I am trying to write a query to back a search API. Specifically for a flag searchDrafts – if the flag is true I have to get rows with status DRAFT and else I have to get all rows that have any status other than DRAFT. In regular SQL, the below query works fine: However, a similar thing in JPQL
Spring Data Jpa Repository not saving entities to database
Im having some difficulties using jpa. Im not getting any exceptions, but I cant save anything to the database. I went from Hibernate to Jpa and everything worked perfectly there. Below are my Files application.properties: Model: Repository: Service: I’m getting a 200 Response when submitting the form, …
Spring Data with Redis: How do I use a different LocalDateTime format or a different convertor?
I have data in my DB for field date with the following format: 2021-09-21 11:25:36. The Redis field is of type TEXT. When I’m trying to read the data from date field from the DB, I get following exception: How can I assign a different convertor to this field in my entity or annotate that my LocalDateTim…
Problem in updating the entity with unidirectional @ManyToOne relation
I have two entities as below and the main problem is when I want to update the AccountRequestStatus entity. I save the integer enum code of AccountRequestStatusEnum in the database to persist the AcountRequest status in the whole application. AccountRequestStatusEnum AccountRequest AccountRequestStatus The fi…
MongoDB Aggregation Pipeline – Count no of records that are matching a complex criteria – (Couldn’t find PersistentEntity for type java.lang.Object!)
I have documents with dynamic fields and I would need to find a count of matching records for a given complex query criteria Example Entity Example Data: Expected Query Criteria: Building such complex Criteria using $match would be too much of implementation, so I was trying to use SPEL evolution through $pro…