-->
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.  [ 7 posts ] 
Author Message
 Post subject: mapping problem with table in Hibernate
PostPosted: Wed Oct 24, 2007 3:45 am 
Newbie

Joined: Sun Oct 21, 2007 9:25 pm
Posts: 4
hello friends,

In am getting an error while retreiving a record from Database. Can any one tel me where i am doing mistake.


Code:
org.hibernate.hql.ast.QuerySyntaxException: emp is not mapped [select pwd from emp where uid='aaaaaaaa']


here emp is my table name the mapping is as follows..

Code:
<hibernate-mapping>
   <class name="login.form.RegisterForm" table="emp">
      <id name="uid" column="uid" type="java.lang.String"></id>
      <property name="pwd1" column="pwd" type="java.lang.String"/>
      <property name="email" column="email" type="java.lang.String"/>
   </class>
   
   <class name="login.form.LoginForm" table="emp">
      <id name="uid" column="name" type="java.lang.String"></id>
   </class>
</hibernate-mapping>


my code in ActionClass is as follows
Code:

try
        {
            String userName = name;
            org.hibernate.Transaction tx = session.beginTransaction();
            String dbPwdCheck = "select uid from emp where uid='"+userName+"'";
            session.createQuery(dbPwdCheck);
            String LFormPwd = LForm.getPwd();
            tx.commit();
            session.flush();
            session.close();
        }
        catch (Exception e)
        {
            System.err.println (e);
        }


thx for anykind of help.
Ajay


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 4:52 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi msg2ajay,

Try this
select emp.uid from RegisterForm emp where emp.uid='"+userName+"'

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 5:17 am 
Newbie

Joined: Sun Oct 21, 2007 9:25 pm
Posts: 4
firt of all thanq for reply,

i have tried with that but i am getting the same error.
Actually with other transation i can connect to the database in case of insert. but i want to get a value from database....!! is ther any other ways to get a single value from database.

thanQ


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 5:19 am 
Newbie

Joined: Sun Oct 21, 2007 9:25 pm
Posts: 4
firt of all thanq for reply,

i have tried with that but i am getting the same error.
Actually with other transation i can connect to the database in case of insert. but i want to get a value from database....!! is ther any other ways to get a single value from database.

thanQ


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 6:53 am 
Newbie

Joined: Wed Oct 24, 2007 2:19 am
Posts: 2
Try query like this
select login.form.RegisterForm.uid from login.form.RegisterForm where login.form.RegisterForm.uid='"+userName+"'";

and let me know if any problem...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 7:28 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
First of all, I see that both RegisterForm and LoginForm maps to same table i.e. emp. Is this a mistake or by design? If this is intended then I think that you need to add enity-name attribute in class mappings.

Moreover while working with HQL you need to specify the class names instead of table names.

_________________
Please rate this post if you find it helpful


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2007 12:34 am 
Newbie

Joined: Sun Oct 21, 2007 9:25 pm
Posts: 4
hi,
i have done a mistake in configuration. i am trying to map to the Data base table name directly .... where i am getting error but i have change my query it is working now...


[code]
String dbPwdCheck = "select Lform.pwd from LoginForm Lform where Lform.uid='"+userName+"'";code]


thanq for posting ur sujjetions.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.