我是Java新手,我遇到了這樣的問題; 我有一個桌面應用程序,JFrame中有2個jComboBox。這個jComboBox的一個是從Personel Table持有Personels,另一個是Personel的標題。當jComboBox1選擇的索引更改發生時,它將獲得personelid並將其標題填入jComboBox2。所以simple.But選擇指數時改變它的標題填充,但顯示類似Ljava.lang.object.xxxxx ...jCombobox JPA HQL內部連接錯誤
ERROR http://img243.yukle.tc/images/7070error.jpg
這裏是我的代碼;
if (jComboBox1.getSelectedItem() !=null) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("SwingDenemePU");
EntityManager em = emf.createEntityManager();
Query sorgu = em.createQuery("from Personel p,Unvan u where p.unvanID = u.unvanID and u.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++) {
items[i] = personelList.get(i);
}
DefaultComboBoxModel def = new DefaultComboBoxModel(items);
jComboBox2.setModel(def);
if if change items [i] = personelList.get(i)to;
Personel personel = personelList.get(i);
items[i]=personel.getPersonelAdSoyad();
我得到在線程異常 「AWT-EventQueue的-0」 java.lang.ClassCastException:[Ljava.lang.Object;不能轉換爲DBClasses.Personel錯誤。
thanx man你解決了我的問題。 – 2009-07-06 19:46:52