0

I am doing this course called enterprise development with java. Our lecture gave us the below code, but i am getting error messages saying the import javax.persistence connot be resolved. Ive been searching for answers but now. Please help.

package Guest; 
 
import java.io.Serializable; 
import java.sql.Date; 
import javax.persistence.Entity; 
import javax.persistence.GeneratedValue; 
import javax.persistence.Id; 
 
 
@Entity 
public class guest implements Serializable { 
    private static final long serialVersionUID = 1L; 
 
    // Persistent Fields: 
    @Id @GeneratedValue 
    Long id; 
    private String name; 
    private Date signingDate; 
 
    // Constructors: 
    public guest() { 
    } 
 
    public guest(String name) { 
        this.name = name; 
        this.signingDate = new Date(System.currentTimeMillis()); 
    } 
 
    // String Representation: 
    @Override 
    public String toString() { 
        return name + " (signed on " + signingDate + ")"; 
    } 
}`

I tried recreating the project, follwed some inline suggestion, enabling JPA.

1 Answers1

1

Take a look at this answer: https://stackoverflow.com/a/74996933/1842599 I quote:

The javax.persistence package was moved to a newly named dependency (jakarta.persistence. The persistence package is part of the larger JPA (Java Persistence API). See Intro to JPA

Can that be the problem in your case, that you're just using the wrong version of JPA?

Andrej Istomin
  • 2,527
  • 2
  • 15
  • 22