0

I am kind new to Spring Boot and trying to how JPA and hibernate works to make my filters and pagination work. Here is my Entity class:

@Entity
@Table(name="V_BOOK")
@Getter @Setter
public class BookView implements Serializable,Comparable<BookView>{
    @EmbeddedId
    private BookViewPK bookViewpk;

    @Column(name="BOOK_NAME", length =100, nullable =false)
    private String bookName;

    @ManytoOne(fetch=FetchType.LAZY)
    @JoinColumn(name = "WK_BOOK_PARAMETER", insertable= false, updatable =false)
    private BookParameter bookParameter;

    //constructors,hashCode, equals etc etc
    //getId();
    //getAuthor();

}

BookParameter class:

@Getter @Setter
public class BookParameter implements Serializable,Comparable<BookParameter>{

    private Long id;
    private String edition;
    private String author;
    private String genor;

    //constructors,hashCode, equals etc etc

}

BookViewPK class:

public class BookViewPK implements Serializable{
    
    @Column(name="BOOK_ID", nullable =false)
    private Long bookId;

    @ManytoOne(fetch=FetchType.LAZY)
    @JoinColumn(name = "WK_BOOK_PARAMETER", nullable =false,insertable= false, updatable =false)
    private BookParameter bookParameter;

    @Column(name="PUBLISHED_DATE", nullable =false)
    private Date pubDate;
}

WK_BOOK_PARAMETER is the primary key here for both the table and view(BOOK_PARAMETERS and V_BOOK) My CONTROLLER FUNCTION USES specification, start, limit, sort, dir as parameters to get all the data at one time.Its just I am not able to filter on author/genor/etc (BookParameters). Now I am trying to fetch these parameters from my UI(basic HTML) as bookParameter.editor/ bookParameter.genor . But I am not able to as it is giving me some specification error (Unable to locate the attribute with the given name [bookParameter.editor] on this Managed Type gemini.mode.BookView . It seems really complex. Now is there a way by which I can make these parameter part of my BookView class?

I tried to get those parameters in the SQL view itself but then it was giving the error of single row subquery returns more than one row error in oracle. So it didn't work. I just want to filter on my Paginated UI by those BookParameters.

0 Answers0