繁体   English   中英

jComboBox给出org.hibernate.PropertyAccessException错误

[英]jComboBox giving org.hibernate.PropertyAccessException error

有2个jComboBox ..和2个Class。 加载表单事件时,它将填充jComboBox1 ,而触发ActionEvent ,它将加载具有jComboBox1选择的另一个类。

我想从jComboBox.GetSelectItem方法获取jComboBox.GetSelectItem不是使用此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();

}

您是否有属性“ unvanID”的获取器/设置器?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM