org.postgresql.util.PSQLException: ERROR: column user0_.id does not exist - Hibernate

后端 未结 6 2156
野性不改
野性不改 2021-02-05 02:47

I have a model class that is mapped to a postgres database using hibernate. My model class is:

@Entity
@Table(name=\"USER\")
public class User {

    @Id 
    @G         


        
6条回答
  •  梦如初夏
    2021-02-05 03:28

    For people getting this exception ,In postgres Whenever you write an Entity Class try to associate it with the correct schema (where your table is present), like this:

    @Entity
    @Table(name = "user", schema = "users_details")
    public class User implements Serializable{
    
        @Column(name = "id")
        Long id;    //long is not recommended
    
       // Other data
    }
    

    As @YCF_L has said Don't use Upper_case letters in a table name or column name otherwise you will get this exception.

    This convention becomes more important when their is a scenario where you have to auto generate the tables from entity classes or vice-versa.

提交回复
热议问题