org.hibernate.MappingException: Could not determine type for commented field

98 Views Asked by At

I am trying to map my database with the Entity class and I can not understand why I have this exception. Here is my class:

@Entity
@Table(name = "process")
public class GeneralProcess implements Serializable {


@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "processid")
private Long ProcessId;
@Column(name = "processname")
private String Name;


//    @Transient
//    private GeneralProcess Analog;
//    @Transient
//    private Topic ProjectTopic;
//    @Transient
//    private String OperatorComment;
//    //@Column(name = "substrate")
//    @Transient
//    private Substrates Substrate;
//    @Transient
//    private List <GeneralLayer> Structure = new 
//ArrayList<GeneralLayer>();
//    @Transient
//    private List <ProcessError> Errors= new ArrayList<ProcessError>
//();
//    @Transient
//    private String EmptyString= "                                                    
//";
//    @Transient
//    private StringBuffer st= new StringBuffer();

public GeneralProcess() {}

public String getName() {return Name;}
public void setName (String s) {Name=s;}
public Long getProcessId() {return ProcessId;}
public void setProcessId (Long s) {ProcessId=s;}


//    public void setAnalog(GeneralProcess analog) {
//        Analog = analog;
//    }

//    public void setProjectTopic (Topic s) {ProjectTopic=s;}
//    public void setOperatorComment (String s) {OperatorComment=s;}
//    public void setSubstrate (Substrates s) {Substrate=s;}
//    public void setStructure (List<GeneralLayer> l) {Structure=l;}
//    public void setErrors (List<ProcessError> l) {Errors=l;}



//    public GeneralProcess getAnalog() {
//        return Analog;
//    }
//
//    public Topic getProjectTopic() { return ProjectTopic; }
//    public String getOperatorComment() {
//        return OperatorComment;
//    }
//    public Substrates getSubstrate() {
//        return Substrate;
//    }
//    public List<GeneralLayer> getStructure() {
//        return Structure;
//    }
//    public List<ProcessError> getErrors() {
//        return Errors;
//    }
//some other methods...

}

my main method:

public static void main(String[] args) {


    StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder()
            .configure( "hibernate.cfg.xml" )
            .build();

    Metadata metadata = new MetadataSources( standardRegistry )
            .addAnnotatedClass( GeneralProcess.class )
            .getMetadataBuilder()
            .build();

    SessionFactory sessionFactory = metadata.buildSessionFactory();

    Session s = sessionFactory.openSession();
    s.beginTransaction();


    List<GeneralProcess> processList = s.createQuery("from GeneralProcess").list();
    processList.stream().forEach((n)-> System.out.println(n.getName()));

    s.getTransaction().commit();
    s.close();

    StandardServiceRegistryBuilder.destroy(standardRegistry);
}

}

So I have the following exception: Exception in thread "main" org.hibernate.MappingException: Could not determine type for: ProcessPackage.Process, at table: process, for columns: [org.hibernate.mapping.Column(Analog)] Why Hibernate try to map Analog field though it is commented? Thank you for any help!

2

There are 2 best solutions below

0
vladwoguer On

Drop your current database(if you have data you want to save, dont't forget to backup it), or change to create on your hibernate.cfg.xml.

0
Mariia On

The problem was not with Hibernate but with Maven. Maven clean fixed it.

Related Questions in MAPPINGEXCEPTION