Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0
Name and version of the database you are using:Oracle 9i
hi! - from an Newbie to Hibernate.
I need resultset by joining two tables (1-many).
Two tables -
Table 1 - SNO (pk) & NAME
Table 2 - SNO (fk) & ID
& two mapping beans MappingBean1 (Table 1) & MappingBean2 (Table 2).
for the sql query - select name from Table 1,Table 2 where
Table 1.SNO = Table 2.SNO AND Table 2.ID='value'
What are the different ways to achive this with mapping?
This is the mapping xml for MappingBean2.hbm.xml am using -
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="true" package="mapping">
<class name="MappingBean2" table="Table 2">
<id name="strSno" column="SNO"/>
<generator class="foreign">
<param name="property">strSno</param> </generator>
<one-to-one name="mappingBean1" class="MappingBean1" outer-join="auto" />
<property name="strId" column="ID" update="false"/>
</class>
</hibernate-mapping>
When I call this -
Query query = session.createQuery("select name from MappingBean1 as map1, MappingBean2 as map2" + "where map1.strSno=map2.strSno" + "map2.id= "+strId);
Iam getting error -Error reading resource: MappingBean2.hbm.xml
Thanks.
Amit