0
2 개의 클래스가 있습니다. jComboBox
.. 2 클래스입니다. 폼로드 이벤트가 jComboBox1
으로 채워지면 ActionEvent
이 실행되면 jComboBox1을 선택하여 다른 클래스를로드합니다.jComboBox에서 org.hibernate.PropertyAccessException 오류가 발생했습니다.
이 id를 가진 다른 클래스를 호출하는 것보다 jComboBox.GetSelectItem
메서드에서 PersonelID를 가져오고 싶습니다. 그러나이 오류를 극복하십시오;
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();
}
예. 있습니다. –
답글이 아닌 답글로 게시 – tharif