2009-07-02 54 views
0

有2 jComboBox ..和2類。當表單加載事件時,它將填充jComboBox1,當ActionEvent觸發時,它將加載另一個類,並選擇jComboBox1。jComboBox給org.hibernate.PropertyAccessException錯誤

我想從jComboBox.GetSelectItem方法得到PersonelID,而不是用這個ID調用另一個類。但是開始這個​​錯誤;

Exception in thread "AWT-EventQueue-0" 
javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: 
could not get a field value by reflection getter of DBClasses.Unvan.unvanID 

這是我的代碼。

private void UnvanAl() 
{ 
if (jComboBox1.getSelectedItem() != null) { 
     EntityManagerFactory emf = Persistence.createEntityManagerFactory("SwingDenemePU"); 
    EntityManager em = emf.createEntityManager(); 
    Query sorgu = em.createQuery("select p from Personel p where p.unvanID = :id"); 
    int id = ((Unvan)jComboBox1.getSelectedItem()).getUnvanID(); 

    sorgu.setParameter("id", id); 
    personelList = sorgu.getResultList(); 
    Object[] items = new Object[personelList.size()]; 
    for (int i = 0; i < personelList.size(); i++) { 
     Personel personel = personelList.get(i); 
     items[i]=personel.getPersonelAdSoyad(); 

    } 

    DefaultComboBoxModel def = new DefaultComboBoxModel(items); 
    jComboBox2.setModel(def); 
    } 

} 


private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) { 
    UnvanAl(); 

} 

回答

0

你有屬性 「unvanID」 getter/setter方法?

+0

是的,我有。 – 2009-07-02 21:37:43