Using Hibernate to Join to Tables -
I am creating an application where people will be able to post comment or articles, and give this rate to users Whether or not the article was helpful to them or not
I currently have two institutions that look like this (non-relevant details are omitted):
Article.java @Entity Article @Id Private Ent article_ID @ManyToOne @JoinColumn (name = "user_id") Personal user user; User.java @Entity user @Id Private Int user_id
I know that one user "voted" on an article for two reasons or not, want a method, 1. Do not let them know let's vote twice, 2. To suggest other articles which can be helpful.
I have experimented with one cascade option in one object in each object
item I User_Article
(which has only two columns, article_ID and user_id) ), However, when I get a waterfall, I'm getting LazyInitilizationException
?
I am looking for Guru to be in any hibernation for guidance on both this implementation and architecture.
Try
@OneToMany (fetch = FetchType.EAGER)
However, it is good to avoid curious loading of large collections. This is why it is lazy, and start it by using Hibernate.in initialize (..)
whenever you are sure you need it or use a HQL query such as:
Comments
Post a Comment