-->
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: inner join not working !!! plz help
PostPosted: Sat Nov 28, 2009 12:16 pm 
Newbie

Joined: Thu Sep 24, 2009 11:49 am
Posts: 8
<?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 suppliers
{
private String SUPPLIER_ID;
private String name;

public suppliers()
{
}
public suppliers(String SUPPLIER_ID,String name)
{
this.SUPPLIER_ID = SUPPLIER_ID;
this.name = name;
}
public void setSupplier_Id(String SUPPLIER_ID)
{
this.SUPPLIER_ID = SUPPLIER_ID;
}

public String getSupplier_Id()
{
return this.SUPPLIER_ID;
}


public void setSupplier_Name(String name)
{
this.name = name;
}

public String getSupplier_Name()
{
return this.name;
}
}





----------------------------------------------

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 nea
r line 1, column 44 [from contact.part a inner join suppliers b on a.supplier_id
=b.Supplier_Id]


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.