2014-04-18 17 views
0

我不能爲了我的生活找出爲什麼Hibernate沒有返回結果,甚至在將類名傳遞給createCriteria() () 方法。我看了一切,不知道我錯過了什麼。我的jsp正在調用一個服務,它調用DAO來檢索數據。HIbernate在createCriteria中傳遞類名時沒有返回結果,或者得到

當我執行這一說法,這是行不通的,事實上,它甚至不運行在所有的SQL(因爲它不是在控制檯中顯示):

List<StyleChooser> temp = sessionFactory.openSession().createCriteria(StyleChooser.class).list(); 

然而,當我運行此,它的工作原理(控制檯顯示休眠:選擇CSS *):

List<StyleChooser> temp = sessionFactory.openSession().createSQLQuery("select * from css").list(); 

StyleChooser.java

@Entity 
@Table(name="css") 
public class StyleChooser { 

@Id 
@GeneratedValue 
@Column(name="ID") 
public Integer id; 

@Column(name="HrefColor") 
public String hrefColor; 

@Column(name="ButtonBackColor") 
public String buttonBackColor; 

@Column(name="ButtonTextColor") 
public String buttonTextColor; 

@Column(name="TextSize") 
public Integer textSize; 

@Transient 
public CommonsMultipartFile file; 

public CommonsMultipartFile getFile() { 
    return file; 
} 
public void setFile(CommonsMultipartFile file) { 
    this.file = file; 
} 
public Integer getId() { 
    return id; 
} 
public void setId(Integer id) { 
    this.id = id; 
} 
public String getHrefColor() { 
    return hrefColor; 
} 
public void setHrefColor(String hrefColor) { 
    this.hrefColor = hrefColor; 
} 
public String getButtonBackColor() { 
    return buttonBackColor; 
} 
public void setButtonBackColor(String buttonBackColor) { 
    this.buttonBackColor = buttonBackColor; 
} 
public String getButtonTextColor() { 
    return buttonTextColor; 
} 
public void setButtonTextColor(String buttonTextColor) { 
    this.buttonTextColor = buttonTextColor; 
} 
public Integer getTextSize() { 
    return textSize; 
} 
public void setTextSize(Integer textSize) { 
    this.textSize = textSize; 
} 
} 

回答

0

發現問題。猜猜這可能會有所幫助,如果我掃描我的sessionFactory中的包。