简体   繁体   中英

@Id annotation cannot be resolved to a type hibernate

so i'm new to hibernate, i'm trying to use the annotations thing but i keep getting "Id cannot be resolved to a type" on the @Id and the same to @Column. How can i solve this ?

I tried the "Fix project setup" by importing the jar files and putting them under the lib folder but in vain.

Here is the code :

 import java.sql.Connection;

 import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import javax.persistence.*;

import org.hibernate.annotations.Columns;
import org.hibernate.annotations.Entity;
import org.hibernate.annotations.Table;
@Entity
@Table(appliesTo = "UTILISATEURS")
public class Utilisateurs {

  public Utilisateurs(String login, String mdp, String status) {
    this.login = login;
    this.mdp = mdp;
    this.status = status;

}
@Id
public int getID_Utilisateur() {
    return ID_Utilisateur;}

public void setID_Utilisateur(int iD_Utilisateur) {
    ID_Utilisateur = iD_Utilisateur;
}
@Column(name="mdp")
public String getMdp() {
    return mdp;
}
public void setMdp(String mdp) {
    this.mdp = mdp;
}


public String getStatus() {
    return status;
}
public void setStatus(String status) {
    this.status = status;
}

 int ID_Utilisateur;
  String mdp;
   String login;
  public String getLogin() {
  return login;
  }

 public void setLogin(String login) {
this.login = login;
}

 String status;
 public static boolean conected_admin = false;
}

That's because you haven't added the necessary files to your classpath.

copy the following jars from the Hibernate Annotations distribution to your CLASSPATH

hibernate-annotations.jar
lib/hibernate-comons-annotations.jar
lib/ejb3-persistence.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM