• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

inner join not working !!! please help  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?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



 
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!