hibernate JPA error : org.hibernate.hql.internal.ast.QuerySyntaxException: users is not mapped
org.hibernate.hql.internal.ast.QuerySyntaxException: users is not
mapped
createQuery
used to create JPQL. In JPQL, you should use the name of the Entity
class instead of the name of the table. So use User
instead of users
in query
em.createQuery("SELECT u FROM User u WHERE u.username = :username AND u.password = :password", User.class);
org.hibernate.hql.internal.ast.QuerySyntaxException: table is not mapped
Finally I found a mistake! Hope this is useful to someone. When doing a request to the database(in my case it Apache Derby), name of base need write the first letter upper case other in lower case.
This is wrong query:
session.createQuery("select first_name from CUSTOMERV").
This is valid query
session.createQuery("select first_name from Customerv").
And class entity must be same name as database, but I'm not sure.
Hibernate QuerySyntaxException: Not Mapped
In Hibernate (and JPA), the mapping is to the class, that is, Notification
. HQL works using your entity classes, and is case sensitive.
With this in mind, your HQL query
from notification where delete_timestamp IS NULL
Should be
from Notification where deleteTimestamp IS NULL
^ ^
|---> class |---> attribute in your class
Hibernate QuerySyntaxException Table is not mapped
Can you try this code for your sessionFactory. It helped me
final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
.configure().build();
sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
Turning Sonar off for certain code
This is a FAQ. You can put //NOSONAR
at the end of the line triggering the warning.
//NOSONAR
For most languages, SonarQube supports the use of the generic mechanism:
//NOSONAR
at the end of the line of the issue. This will suppress all issues - now and in the future - that might be raised on the line.
I prefer using the FindBugs mechanism though, which consists in adding the @SuppressFBWarnings annotation:
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = "NAME_OF_THE_FINDBUGS_RULE_TO_IGNORE",
justification = "Why you choose to ignore it")
SonarQube JavaScript disable a part of code
SonarQube provides plenty of options for ignoring issues in specific files and/or code blocks, see Narrowing the Focus documentation (and to your specific case: look for Ignore Issues in Blocks).
Related Topics
How to Do Post Request With Raw Data Via Spring Rest Template
How to Count the Rows in Hibernate Query Language
How to Send Text to Textarea in Div Element Using Selenium
How to Read Empty Cells of an Excel File Using Poi
Unable to Deploy Spring Boot 2 Application Due to Hikaripool Exception During Pool Initialization
How to Retrieve Mapping Table Name for an Entity in JPA At Runtime
How to Get Amount of Tens in a Int
Cannot Load Driver Class: Com.Mysql.Jdbc.Driver Spring Boot
Why How to Declare a Variable Without an Initial Value
Java - Reading Text File as an Integer and Split Each Line into Array
Jackson Serializes a Zoneddatetime Wrongly in Spring Boot
How to Get My Loops to Display Horizontally Instead of Vertically
Turning Sonar Off for Certain Code
Android Tv Recyclerview Set Next Focus of Its Item
Creating Random Numbers With No Duplicates
How to Wait for @Jmslistener Annotated Method to Complete in Junit