[英]jComboBox giving org.hibernate.PropertyAccessException error
There is 2 jComboBox
.. and 2 Class . 有2个
jComboBox
..和2个Class。 When form load event it will fill jComboBox1
,when ActionEvent
fired it will load another class with selection of the jComboBox1. 加载表单事件时,它将填充
jComboBox1
,而触发ActionEvent
,它将加载具有jComboBox1选择的另一个类。
I wanna get PersonelID from jComboBox.GetSelectItem
method than call another class with this id. 我想从
jComboBox.GetSelectItem
方法获取jComboBox.GetSelectItem
不是使用此ID调用另一个类。 But gettin this error ; 但是遇到这个错误;
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
And Here is my Codes.; 这是我的代码。
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.