-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: have some error when trying to create a hibernate applicatio
PostPosted: Mon Jul 21, 2014 5:50 am 
Newbie

Joined: Mon Jul 21, 2014 5:44 am
Posts: 1
i'm new in hibernate.i'm trying to create a hibernation application connect to postgress database but how some problem
this is my file hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">
org.postgresql.Driver
</property>
<property name="hibernate.connection.url">
jdbc:postgresql://localhost:5432/postgres
</property>
<property name="hibernate.connection.username">postgres</property>
<property name="connection.password">123456</property>
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect
</property>
<property name="cache.provider_class">
org.hibernate.cache.internal.NoCacheProvider
</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">none</property>

<mapping resource="com/hibernate/crud/simple/StudentContact.hbm.xml"/>
</session-factory>

</hibernate-configuration>

My file mapping
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.hibernate.crud.simple">

<class name="StudentContact" table="student_contact" lazy="true">
<id name="student_id" column="iStudentID">
<generator class="native"/>
</id>
<property name="student_mobile_number" type="long" column="sMobile" />
<property name="student_email_id" type="string" column="sEmail"/>
</class>

</hibernate-mapping>

My main method

package com.hibernate.crud.simple;

import java.util.Iterator;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.hibernate.util.HibernateUtil;

public class StudentListHibernate {

public List listStudent()
{
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction transaction = null;
List student = null;
try {
transaction = session.beginTransaction();
student = session.createQuery("SELECT * FROM \"StudentContact\"").list();
transaction.commit();
} catch (HibernateException e) {
transaction.rollback();
e.printStackTrace();
} finally {
session.close();
}
return student;
}

public static void main(String[] args) {
List<StudentContact> student = null;
StudentListHibernate sh = new StudentListHibernate();
student = (List<StudentContact>)sh.listStudent();
for (Iterator<StudentContact> iterator = student.iterator(); iterator.hasNext();)
{
StudentContact listHibernate = (StudentContact)iterator.next();
System.out.println("");
System.out.print(listHibernate.getStudent_id());
System.out.print(" : ");
System.out.print(listHibernate.getStudent_mobile_number());
System.out.print(" : ");
System.out.print(listHibernate.getStudent_email_id());
}
}
}

and here is my error message
Jul 21, 2014 4:01:58 PM org.hibernate.hql.internal.ast.ErrorCounter reportError
ERROR: line 1:8: unexpected token: *
Jul 21, 2014 4:01:58 PM org.hibernate.hql.internal.ast.ErrorCounter reportError
ERROR: line 1:8: unexpected token: *
line 1:8: unexpected token: *
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:1256)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1030)
at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:700)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:294)
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:157)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:266)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:214)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:192)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1537)
at com.hibernate.crud.simple.StudentListHibernate.listStudent(StudentListHibernate.java:21)
at com.hibernate.crud.simple.StudentListHibernate.main(StudentListHibernate.java:35)

Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.hql.internal.antlr.HqlBaseParser.recover(Lantlr/RecognitionException;Lantlr/collections/impl/BitSet;)V
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:1319)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1030)
at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:700)
at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:294)
at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:157)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:266)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:214)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:192)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1537)
at com.hibernate.crud.simple.StudentListHibernate.listStudent(StudentListHibernate.java:21)
at com.hibernate.crud.simple.StudentListHibernate.main(StudentListHibernate.java:35)

pls help me if u know what happend to me and how to fix it


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.