<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="contact.part" table="part">
<id column="Part_Id" name="Part_Id" type="string"/>
<property column="" name="Supplier_Id" type="string"/>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="contact.suppliers" table="suppliers">
<id column="Supplier_Id" name="Supplier_Id" type="string"/>
<property column="" name="Supplier_Name" type="string"/>
</class>
</hibernate-mapping>
-------------------------
package contact;
public class part
{
private
String PART_ID;
private String Supplier_Id;
public part()
{
}
public part(String PART_ID,String Supplier_Id)
{
this.PART_ID = PART_ID;
this.Supplier_Id = Supplier_Id;
}
public void setPart_Id(String PART_ID)
{
this.PART_ID = PART_ID;
}
public void setName(String Supplier_Id)
{
this.Supplier_Id = Supplier_Id;
}
public String getPart_Id()
{
return this.PART_ID;
}
public String getName()
{
return this.Supplier_Id;
}
public void setSupplier_Id(String Supplier_Id)
{
this.Supplier_Id = Supplier_Id;
}
public String getSupplier_Id()
{
return this.Supplier_Id;
}
}
-------------------------------------------------------------------
package contact;
public class part
{
private String PART_ID;
private String Supplier_Id;
public part()
{
}
public part(String PART_ID,String Supplier_Id)
{
this.PART_ID = PART_ID;
this.Supplier_Id = Supplier_Id;
}
public void setPart_Id(String PART_ID)
{
this.PART_ID = PART_ID;
}
public void setName(String Supplier_Id)
{
this.Supplier_Id = Supplier_Id;
}
public String getPart_Id()
{
return this.PART_ID;
}
public String getName()
{
return this.Supplier_Id;
}
public void setSupplier_Id(String Supplier_Id)
{
this.Supplier_Id = Supplier_Id;
}
public String getSupplier_Id()
{
return this.Supplier_Id;
}
}
--------------------------------------------------------------------------
package contact;
import org.hibernate.*;
import org.hibernate.cfg.*;
import java.util.*;
public class JoinClauseDemo
{
public static void main(String args[])
{
Session session = null;
SessionFactory factory = null;
try
{
factory = new Configuration().configure().buildSessionFactory();
session = factory.openSession();
String sql = "from part a inner join suppliers b on a.supplier_id=b.Supplier_Id";
Query q = session.createQuery(sql);
List l = q.list();
Iterator i = l.iterator();
Display(i);
session.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
static void Display(Iterator i)
{
while(i.hasNext())
{
Object []o = (Object[])i.next();
System.out.print(o[0]);
System.out.print("\t" +o[1]);
System.out.println("\t" +o[2]);
}
}
}
----------------------------
ERROR
[java] 21:44:28,703 ERROR PARSER:33 - line 1:44: unexpected token: on
[java] org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on near line 1, column 44 [from contact.part a inner join suppliers b on a.supplier_id
=b.Supplier_Id]inner join not working please help