0

How can I use like operator in one to ManyRealtion ship.Please check my code below for my Situation.

I have Org Class and DeptClass with One - Many Realtion ship

Org.java

@Entity
@Table(name="TBL_STD_ORGANIZATION")
public class Organization implements Serializable  {
 @Id
@GeneratedValue
@Column(name="FLD_ORG_ID")
private Long organizationId;

@Column(name="FLD_ORG_NAME")
private String orgName;

@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
private java.util.List<Department> listOfDepartMents = new java.util.ArrayList<Department>();

//setter and getter methods
}

Dept.java

     @Entity
      @Table(name="TBL_STD_DEPARTMENT")
      public class Department implements Serializable { 

@Id
@GeneratedValue
@Column(name = "FLD_DEPARTMENT_ID")
private Long departmentId;

@Column(name = "FLD_DEPARTMENT_NAME")
private String departmentName;
   // Setter and getter methods

}

Now i have orgName but for deptName i have only first two characters(for like operator) based on this orgName I fire the query but i got number of Department Objects for the OrgName.I want to short those departmetns by using like how can i do this any one help me..I am using HQL

4

1 回答 1

0

您可以从这里找到有关一对多关系的更多信息

于 2013-10-10T13:13:08.340 回答