<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on">
<div dir="ltr" style="text-align: justify;" trbidi="on"><b>The following exception is very common if you are the beginner for hibernate.</b></div>
<pre class="highlight" name="code">SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in
[jar:file:/D:/HIBERNATE/lib/hibernate-annotations-jar-files/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/E:/study%20materials/video%20tutorials/JAVA_J2EE_VIDEO_TUTORIALS/hibernate/hibernate-annotations-jar-files/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/D:/HIBERNATE/lib/slf4j-simple-1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
log4j:WARN No appenders could be found for logger
(org.hibernate.type.BasicTypeRegistry).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig
for more info.
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException:
student is not mapped [from student]
 at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
 at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:111)
 at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)
 at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:327)
 at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3441)
 at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3325)
 at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:733)
 at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:584)
 at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
 at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:244)
 at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
 at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
 at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
 at org.hibernate.engine.query.HQLQueryPlan.<;init>;(HQLQueryPlan.java:101)
 at org.hibernate.engine.query.HQLQueryPlan.<;init>;(HQLQueryPlan.java:80)
 at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
 at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
 at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
 at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
 at kumar.saroj.ReadStudent.main(ReadStudent.java:18)
 this is the complete exception hierarchy.
</pre>
<div align='center' id="ads-id"></div>
</div>
<p>The above <i>QuerySyntaxException </i>is thrown when we are not mapping the table name properly. The first time hibernate users<br />
can be seen this error because you will map the table name directly in the query. That will not work in the hibernate. You will have to<br />
map the class name that is mapped in the Hibernate configuration file. Look into the following example:</p>
<pre class="highlight" name="code">public static void main(String[] args) 
 {
 //Create session factory object
 SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
 //getting session object from session factory
 Session session = sessionFactory.openSession();
 //getting transaction object from session object
 session.beginTransaction();
 Query query = session.createQuery("from student");
 List<;Student>; students = query.list();
 for(Student student : students)
 {
System.out.println("Roll Number: "+student.getRollNumber()+", Student Name: "+student.getStudentName()+", Course: "+student.getCourse());
 }
 session.getTransaction().commit();
 sessionFactory.close();
 }
</pre>
</div>
<p>
The above code give exception mention in above.</p>
<p><b>Description:</b></p>
<p>Your query is not a SQL query. It&#8217;s a HQL query. It thus should not use table names, but entity class names (from Student instead of from student). </p>
<p> In above code we using following line. Here &#8220;student&#8221; is not entity name by default entity name is same as class name so we have use &#8220;Student&#8221; instead of &#8220;student&#8221; because of HQL is pick entity name not table name(table name is &#8220;student&#8221;). So please we care about this concern. </p>
<pre class="highlight" name="code">Query query = session.createQuery("from student");
</pre>
<p>
<b>If you using the following code then you got successfully running. </b></p>
<pre class="highlight" name="code">public static void main(String[] args) 
 {
 //Create session factory object
 SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
 //getting session object from session factory
 Session session = sessionFactory.openSession();
 //getting transaction object from session object
 session.beginTransaction();
 Query query = session.createQuery("from Student");
 List<;Student>; students = query.list();
 for(Student student : students)
 {
System.out.println("Roll Number: "+student.getRollNumber()+", Student Name: "+student.getStudentName()+", Course: "+student.getCourse());
 }
 session.getTransaction().commit();
 sessionFactory.close();
 }
</pre>
<p><b>Here the class names is case sensitive.</b></p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/get-http-header-in-jax-rs/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/hibernate-search-api-hibernate-4-on/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '405'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…