Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate

 
poonam dahiya
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i m facing a problem i m new to hibernate.
i created the cfg file,hbm file,i am asked to select all the rows from column but i m getting this Error:
No data type for node: org.hibernate.hql.ast.IdentNode +-[ALIAS_REF] IdentNode: 'FIRSTNAME' {alias=FIRSTNAME, no from element}
javascript: x()
Confused

please help me out.i am pasting my cfg file hbm file..too....
thanks in advance...
plzzzzzzzzzzzz help me........




contact.hbm.xml


hibernate.cfg.xml



Contact.java file


[ Edited to use code tags - Paul Sturrock ]
[ June 16, 2008: Message edited by: Paul Sturrock ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

String Oracle_QUERY ="Select FIRSTNAME,LASTNAME,EMAILID,ID from Contact";

Contact does not have properties called FIRSTNAME,LASTNAME,EMAILID, or ID. Remember that with HQL you are querying the class not the database table directly.
 
Bhaskar GR
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session session=sf.openSession();
Transaction tx=session.beginTransaction();
RegularLogger.logInfo(RegularDAOImpl.class,"Query of the level_table");
Query q1=session.createQuery("from Contact as l");
List l=q1.list();
Iterator i=l.iterator();
while(i.hasNext())
{-----------
}
 
ksrk mahidhar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am also facing similar problem can any one help me how to workout this issue.
 
ksrk mahidhar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks i got solution

just use below code

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();

//Using from Clause
String SQL_QUERY ="from Contact";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate();it.hasNext();){
Contact contact=(Contact)it.next();
System.out.println("ID IS : " + contact.getId());
System.out.println("FirstName IS : " + contact.getFirstName());
System.out.println("LastName IS : " + contact.getLastName());
System.out.println("Email IS: " + contact.getEmail());
}
session.close();



you will get out put
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic