-->
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.  [ 2 posts ] 
Author Message
 Post subject: Not able to recognize Named Query - pls help
PostPosted: Mon Aug 02, 2010 11:21 pm 
Newbie

Joined: Fri Jul 30, 2010 2:02 pm
Posts: 6
Hi,
Program is not able to recognize Named query put in hbm file.
Below is my HBM file

Student.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="edu.model.Student" table="STUDENT">
<id name="studentNo" column="STUDENTNO">
<generator class="sequence" />
</id>
<property name="studentName" column="SNAME"/>
<query name = "HQLStudent1" >
<![CDATA[select student.studentNo, student.studentName from Student student
where student.studentNo >:studentNo]]>
</query>
</class>
</hibernate-mapping>


Below is Hibernate Config file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:SURESH</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.use_sql_comments">true</property>
<mapping resource="edu/mapping/Student.hbm.xml" />
<mapping resource="edu/mapping/Employee.hbm.xml" />
</session-factory>
</hibernate-configuration>


Below is my Java file

public static void main(String[] args) {

Session session = SessionUtil.currentSession();
Query query = session.getNamedQuery("HQLStudent1");
query.setLong("studentNo",new Long(1));

List stuList = query.list();

Iterator iterator = stuList.iterator();

while(iterator.hasNext()){
Student student = (Student)iterator.next();
System.out.println(student);
}
}


}


Pls, help


Top
 Profile  
 
 Post subject: Re: Not able to recognize Named Query - pls help
PostPosted: Wed Aug 04, 2010 12:21 pm 
Newbie

Joined: Fri Jul 30, 2010 2:02 pm
Posts: 6
Could anybody reply to this thread


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

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.