-->
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: Problem in mapping database table
PostPosted: Tue May 08, 2012 1:18 am 
Newbie

Joined: Tue May 08, 2012 1:05 am
Posts: 1
I am populating a dropdown with Company Name values using Hibernate but getting following compile time error:

Exceptionorg.springframework.orm.hibernate3.HibernateQueryException: company is not mapped [from company order by company_name]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: company is not mapped [from company order by company_name]



In database table name is company with column company_id as bigint,company_name as varchar
My mapping file is:Company.hbm.xml as follows:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated May 9, 2011 1:56:44 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="in.nic.pojo.Company" table="company" schema="mfms">
<id name="id" type="string">
<column name="company_id" />
<generator class="identity" />
</id>
<property name="company" type="string">
<column name="company_name" />
</property>
</class>
</hibernate-mapping>

And the Company.java source file:

package in.nic.pojo;


import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

@XmlAccessorType(XmlAccessType.NONE)
public class Company
{
// private String id;
private String id;
private String company;
public Company()
{
super();
}

public Company(String id, String company)

{
this.id = id;
this.company = company;
}
public String getId()
{

return id;
}
public void setId(String id) {
this.id = id;
}

public String getCompany() {
return company;
}

public void setCompany(String company) {
this.company = company;
}

}

CompanyManagerImpl.java:

package in.nic.manager.impl;

import in.nic.manager.CompanyManager;

import in.nic.pojo.Company;

import in.nic.util.BaseException;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class CompanyManagerImpl extends HibernateDaoSupport implements CompanyManager
{

public List<Company> findAll() throws BaseException
{
System.out.println("hi--------------");
List<Company> companyList = getHibernateTemplate().find("from company order by company_name");
return companyList;
}

}


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.