i have many to many relationship between book and author, i have 3 tables: author, book and author_book. i can add data to db without a problem, but when i want to get an author or a book by its id i get an error: LazyInitialization failed to lazily … I want to use FetchType.LAZY and get the instance of
Tag: spring-data-jpa
Duplicates in Output Java Spring Boot JPA
I’m working on an application with following Entities and code: The RestController for MotionPicture: My DB Table: clip columns: id(1-100 unique), date, size Table: motion_picture columns: id(1-100 unique), date, size, duration association table: motion_picture_clips columns: motion_picture_id (1-100 random), clips_id (1-100 unique) When I run the programm and make a the getRequest in Postman (getById and getAll) –> I’ll get duplicated
Spring boot Build issue
**Custom configuration for mail sender ** @Configuration public class EmailConfig { private EmailProperties emailProp; @Autowired ConstantRepository …
How to get Page as result in Querydsl query with fetch or fetchResults properly?
Hi what i trying to achieve here is, i want to submit Pageable data into QueryDsl query and get the result as Page, how can i do it properly? here is what i do until now : here is my controller : in my controller i submit StockViewByProductCodesDto which is looked like this : and here is my service :
Join tables in spring data jpa
I have an issue in joining two tables column. I have two entities Status Report and Employee. and I want the data of employee inside StatusReport. Another class is the employee: As you can see employee entity itself have some other joins on other tables. Which is a deparment table. When I join Status Report with Employee I get Sql
Mapping a Star Schema with Spring Boot JPA
I’m struggling to identify the right annotations to use to map a star schema with Spring Boot JPA. Let’s consider 3 tables: DIM_One (1)——–(1..n) FACT (1..n) ———— (1) DIM_Two DIM_One and DIM_Two both have an id that is their primary key. FACT’s primary key is the combination of (DIM_One_pk, DIM_Two_pk) For now, the annotations in my DIM tables are similar
How to Avoid nested for Loops in java to get the heirarchical data?
// This method will return the list of reference names, in this method I wrote the code using nested //for-loops this handle only 3 subfolders set what if there is one more subfolder and how to handle it //without for loops, OverAll I should handle it dynamically //for-loops this handle only 3 subfolders set what if there is one more
Querying with ManyToOne association results in SQLException
I am trying out a simple use case for many-to-one association with Spring Data JPA but it is resulting in an SQLException. Model is of typical Order and OrderItem classes. Order OrderItem Unit test Unit test passes. But if I uncomment the line to find all items from OrderItemRepository it fails with following exception: What could be missing here ?
I have an error but dependencies include in gradle root and gradle module config, why?
I have root config gradle.build and have build.gradle in module After download dependencies and add in models annotations like @Entity, @Table @Id and etc. i have an error: cannot find symbol @Entity ^ symbol: class Entity But i have spring-boot-starter-jpa in dependencies, i don’t know why in module i can’t use dependencies. Answer With dependencyManagement you only manage dependencies like
Spring JPA repository interface and default methods use case
I am currently wondering whether a particular use case could be elegantly addressed by using a default interface method inside a JPA repository. Suppose we have the following entity and supporting types: I need to be able to query a list of SomeEntity based on combination of Status enumeration values. With Spring JPA, its respective repository could look like this: