Previous | Home | Next |
This type of association relates one entity object to many object of another entity.
Example:-
Relationship between a department and employee.Many employee can work in a single department.
hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> <session-factory> <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property> <property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property> <property name="connection.username">system</property> <property name="connection.password">system</property> <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <mapping resource="listAndBag.hbm.xml"/> </session-factory> </hibernate-configuration>
Batch.java
package r4r; public class Batch { int id; String time,course,mode; Trainer trainer; public Batch() { super(); } public Batch(String time, String course, String mode,Trainer t) { super(); this.time = time; this.course = course; this.mode = mode; this.trainer=t; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public String getCourse() { return course; } public void setCourse(String course) { this.course = course; } public String getMode() { return mode; } public void setMode(String mode) { this.mode = mode; } public Trainer getTrainer() { return trainer; } public void setTrainer(Trainer trainer) { this.trainer = trainer; } }
Previous | Home | Next |