• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Hibernate

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a small application in hibernate but i am getting exception please help me i am new to hibernate
this is my client application
import org.hibernate.cfg.*;
import org.hibernate.*;
import java.util.*;
class TestClient
{
public static void main(String args[])throws Exception{
Configuration conf=new Configuration();
conf.configure();
SessionFactory factory=conf.buildSessionFactory();
Session ses=factory.openSession();
Transaction tx=ses.beginTransaction();
String s="select * from employee";
SQLQuery q=ses.createSQLQuery(s);
q.addEntity(EmpBean.class);
List l=q.list();
for(int i=0;i<l.size();i++)
{
EmpBean e=(EmpBean)l.get(i);
System.out.println("name=================================="+e.getFname());
}

tx.commit();
ses.close();
factory.close();


Exception is:
javac *.java
TestClient.java:13: cannot find symbol
symbol : class SQLQuery
location: class TestClient
SQLQuery q=ses.createSQLQuery(s);
^
cannot find symbol
symbol : method createSQLQuery(java.lang.String)
location: interface org.hibernate.Session
SQLQuery q=ses.createSQLQuery(s);

please help me
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Use Code Tags

2) That's not an exception, that is a compiler error. An exception happens at runtime, a compiler error happens at compile time.

That said, I do not understand these errors. The first one says it cannot find class SQLQuery but org.hibernate.SQLQuery exists and you have already imported org.hibernate.* - that should include SQLQuery. The second one says that method createSQLQuery(String) does not exist in org.hibernate.Session, yet the Javadoc shows me otherwise.

Do you have the latest version of Hibernate? Perhaps this class and this method have been added after the version you are using has been released. Try upgrading first.
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic