DEV Community

Discussion on: Bean can not resolve jpa /hibernate

Collapse
 
dineshftu profile image
dineshftu

Please let me see your post entity and person entity classes to see whether i can resolve this for you.

Collapse
 
soniadev profile image
Sonia-dev

package com.example.demo.model;

import javax.persistence.*;
import javax.persistence.OneToMany;
import java.util.Collection;
import java.util.Date;
import java.util.List;

@Entity
public class Post {
public long getId() {
return id;
}

public void setId(long id) {
    this.id = id;
}

public void setTitle(String title) {
    this.title = title;
}

public void setBody(String body) {
    this.body = body;
}

public void setCreatedDate(Date createdDate) {
    this.createdDate = createdDate;
}

public String getTitle() {
    return title;
}

public String getBody() {
    return body;
}

public Date getCreatedDate() {
    return createdDate;
}

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String title;
private String body;
private Date createdDate;

public List<Comment> getComments() {
    return comments;
}

public void setComments(List<Comment> comments) {
    this.comments = comments;
}
@OneToMany(mappedBy = "post", cascade = CascadeType.REMOVE)
private List<Comment>comments;
Enter fullscreen mode Exit fullscreen mode

}

Collapse
 
soniadev profile image
Sonia-dev

package com.example.demo.model;

import javax.persistence.*;
import java.util.Collection;
@Table
@Entity
public class Person {
@id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String username;
public String getEmail() {
return email;
}

public void setEmail(String email) {
    this.email = email;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

private String email;
private String password;
public Person() {
}

public Person(String name) {
    this.username = name;
}

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public String getName() {
    return username;
}

public void setName(String name) {
    this.username = name;
}
Enter fullscreen mode Exit fullscreen mode

}