Spring boot org.hibernate.hql.internal.ast.QuerySyntaxException: Utilisateur is not mapped (with MYSQL)

zaafrani

Hi I am using Mysql with Spring boot and when i am using the query method with the CrudRepository hibernate can't match with my table.

My User class :

@Entity

@Table(name="Utilisateur")

public class User{

    @Id
    private long id;
    @Column(name="nom")
    private String nom;
    @Column(name="prenom")
    private String prenom;
    @Column(name="admin")
    private boolean admin;
    @Column(name="actif")
    private boolean actif;
    @Column(name="logins")
    private String logins;
    @Column(name="email")
    private String email;
    @Column(name="naissance")
    private String naissance;
    @Column(name="pwd")
    private String pwd;
    @Column(name="compte")
    private String compte;

    public User(){

    }

    public User(String nom, String prenom, boolean admin, boolean actif, String logins, String email, String naissance, String pwd, String compte) {
        this.nom = nom;
        this.prenom = prenom;
        this.admin = admin;
        this.actif = actif;
        this.logins = logins;
        this.email = email;
        this.naissance = naissance;
        this.pwd = pwd;
        this.compte = compte;
    }
/*Getters and setters*/
}

My second class implement CrudRepository :

@Repository
public interface UserDao  extends CrudRepository<User,Long>{

    public User findByEmail(String email);
    public List<User> findByLogins(String logins);
    public List<User> findAll();

    @Query("SELECT u FROM Utilisateur u where id=?1")
    public User findById(int Id);
}

And for finish i am using a class for test with junit :

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = RecipyApplication.class)
@WebAppConfiguration
public class RecipyApplicationTests {

    @Autowired
    private UserDao userDao;
    @Test
    public void should_get_user_by_id(){
        User user = userDao.findById(1);
        Assert.assertNotNull("the id can't be null ",user);
    }

}

And i don't understand why hibernate can't match with my database when i am using @Query. Thank you

Madhusudana Reddy Sunnapu

Instead of SELECT u FROM Utilisateur use SELECT u FROM User in the @Query.

We should use entity name rather than table name.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Spring boot org.hibernate.hql.internal.ast.QuerySyntaxException: Utilisateur is not mapped (with MYSQL)

From Dev

Spring boot multiple module project org.hibernate.hql.internal.ast.QuerySyntaxException: is not mapped

From Dev

Hibernate - org.hibernate.hql.internal.ast.QuerySyntaxException: Client is not mapped

From Java

org.hibernate.hql.internal.ast.QuerySyntaxException: table is not mapped

From Dev

org.hibernate.hql.internal.ast.QuerySyntaxException: is not mapped

From Dev

Spring, Spring Data JPA: org.hibernate.hql.internal.ast.QuerySyntaxException: Test is not mapped

From Dev

I got an org.hibernate.hql.internal.ast.QuerySyntaxException: is not mapped exception

From Dev

org.hibernate.hql.internal.ast.QuerySyntaxException: EdbmsEmployee is not mapped [from EdbmsEmployee edbmsEmployee where edbmsEmployee.employeeid=?]

From Dev

I got an org.hibernate.hql.internal.ast.QuerySyntaxException: is not mapped exception

From Dev

org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token

From Dev

Selecting nested Hibernate immutable objects throws org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: new

From Dev

org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: '1.id'

From Dev

org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: * near line 1

From Dev

org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: Apr near line 1, column 81

From Dev

org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: '1.id'

From Dev

org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: distinct near line 1, column 17

From Dev

org.hibernate.hql.ast.QuerySyntaxException: unexpected token:

From Dev

How to solve org.hibernate.hql.ast.QuerySyntaxException: Exception

From Dev

org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor

From Dev

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: order near line 1, column 17 for absolutely unclear reasons

From Dev

org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class

From Dev

java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException MS-Sql Server

From Dev

No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode HQL

From Dev

org.hibernate.hql.ast.QuerySyntaxException:on near line 1, column 102 [FROM com.strutsProject.dto.EventClubTb

From Dev

org.hibernate.hql.ast.QuerySyntaxException:on near line 1, column 102 [FROM com.strutsProject.dto.EventClubTb

From Dev

What does org.hibernate.hql.internal.ast.tree.Node means in jmap heap dump

From Dev

Hibernate QuerySyntaxException, Table not mapped

From Dev

Spring boot + Hibernate - User is not mapped

From Dev

could not instantiate QueryTranslatorFactory: org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory

Related Related

  1. 1

    Spring boot org.hibernate.hql.internal.ast.QuerySyntaxException: Utilisateur is not mapped (with MYSQL)

  2. 2

    Spring boot multiple module project org.hibernate.hql.internal.ast.QuerySyntaxException: is not mapped

  3. 3

    Hibernate - org.hibernate.hql.internal.ast.QuerySyntaxException: Client is not mapped

  4. 4

    org.hibernate.hql.internal.ast.QuerySyntaxException: table is not mapped

  5. 5

    org.hibernate.hql.internal.ast.QuerySyntaxException: is not mapped

  6. 6

    Spring, Spring Data JPA: org.hibernate.hql.internal.ast.QuerySyntaxException: Test is not mapped

  7. 7

    I got an org.hibernate.hql.internal.ast.QuerySyntaxException: is not mapped exception

  8. 8

    org.hibernate.hql.internal.ast.QuerySyntaxException: EdbmsEmployee is not mapped [from EdbmsEmployee edbmsEmployee where edbmsEmployee.employeeid=?]

  9. 9

    I got an org.hibernate.hql.internal.ast.QuerySyntaxException: is not mapped exception

  10. 10

    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token

  11. 11

    Selecting nested Hibernate immutable objects throws org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: new

  12. 12

    org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: '1.id'

  13. 13

    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: * near line 1

  14. 14

    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: Apr near line 1, column 81

  15. 15

    org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: '1.id'

  16. 16

    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: distinct near line 1, column 17

  17. 17

    org.hibernate.hql.ast.QuerySyntaxException: unexpected token:

  18. 18

    How to solve org.hibernate.hql.ast.QuerySyntaxException: Exception

  19. 19

    org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor

  20. 20

    Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: order near line 1, column 17 for absolutely unclear reasons

  21. 21

    org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class

  22. 22

    java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException MS-Sql Server

  23. 23

    No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode HQL

  24. 24

    org.hibernate.hql.ast.QuerySyntaxException:on near line 1, column 102 [FROM com.strutsProject.dto.EventClubTb

  25. 25

    org.hibernate.hql.ast.QuerySyntaxException:on near line 1, column 102 [FROM com.strutsProject.dto.EventClubTb

  26. 26

    What does org.hibernate.hql.internal.ast.tree.Node means in jmap heap dump

  27. 27

    Hibernate QuerySyntaxException, Table not mapped

  28. 28

    Spring boot + Hibernate - User is not mapped

  29. 29

    could not instantiate QueryTranslatorFactory: org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory

HotTag

Archive