File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes hibernate mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate mapping" Watch "hibernate mapping" New topic
Author

hibernate mapping

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

hi all,

Here i have attached my two table(xml)..tell me how to map this two table..i want to fetch value from two table..i tried but i could not..i visited hibernate.org website also..still i failed



this is my Employeeclass


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file generated by seetharaman //precision="22" scale="0"
-->
<hibernate-mapping>
<class name="com.genuitec.hibernate.Employees" table="EMPLOYEES">
<id name="username" type="java.lang.String">
<column name="username" />
<generator class="increment" />
</id>
<property name="password" type="java.lang.String">
<column name="password" />
</property>
<property name="roleid" type="java.lang.String">
<column name="roleid" />
</property>
<property name="name" type="java.lang.String">
<column name="name" />
</property>
<property name="phone" type="java.lang.String">
<column name="phone" />
</property>
<property name="email" type="java.lang.String">
<column name="email" />
</property>
<property name="depid" type="java.lang.String">
<column name="depid" />
</property>

</class>
</hibernate-mapping>


this is my department class

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file generated by seetharaman //precision="22" scale="0"
-->
<hibernate-mapping>
<class name="com.genuitec.hibernate.Departments" table="departments">
<id name="depid" type="java.lang.String">
<column name="DEPID" />
<generator class="assigned" />
</id>
<property name="depname" type="java.lang.String">
<column name="DEPNAME" />
</property>


</class>


----> please any one help me



thanks & regards,

seetharaman
Amit Y Desai
Ranch Hand

Joined: Dec 06, 2007
Posts: 35
a good option is to download hibernate synchronizer from net..Its a plugin for eclipse..it connects with database and asks you which tables you want to map to...and next next next..you are done..all java files + hbm files + mapping in hibernate.cfg.xml...all done
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: hibernate mapping