2017-07-20 7 views
1

列挙型クラスの多くのマッピングには多くの基準の制限どのように休止状態列挙

public enum Days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,SATURDAY } 

Modelクラス

@Fetch(FetchMode.SUBSELECT) 
@ElementCollection(targetClass = Days.class, fetch = FetchType.EAGER) 
@JoinTable(name = "bus_days", joinColumns = @JoinColumn(name = "bus_master_id")) 
@Column(name = "day", nullable = false) 
@Enumerated(EnumType.ORDINAL) 
private Set<Days> days = new HashSet<Days>(); 
// getter setter 

休止クエリでエラーが発生しました:Eclipseのコンソールで得られた

Criteria criteria = null; 
criteria = session.createCriteria(Model.class) 
      .add(Restrictions.eq("fromCity.id", fromCity)) 
      .add(Restrictions.eq("toCity.id", toCity)) 
      .add(Restrictions.eq("days", days.ordinal()));//error in this line 
      return (List<Model>) criteria.list(); 

エラー;

Caused by: java.sql.SQLException: No value specified for parameter 3 
ERROR: No value specified for parameter 3 
org.hibernate.exception.SQLGrammarException: could not extract ResultSet 

あなたはdays.ordinal()で比較を行うべきではない、

答えて

0

を私を助けて、あなたは自分で数字に変換休止状態、のみdaysで比較する必要があります。

+0

_thanq brother_ – Vinay