I'm new to hibernate and I'm using db-derby 10.7.1.1 and I have a little problem. I've got a database with 3 tables with data that I need and 2 tables that hibernate created for auto incrementation.
the thing is I need to populate a jtable with the data that I've got in one table but I'm getting an exception: Hibernate: select cartemodel0_.codcarte as codcarte8_, cartemodel0_.Autor as Autor8_, cartemodel0_.imprumut as imprumut8_, cartemodel0_.titlu as titlu8_ from CarteModel cartemodel0_ Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
the table name in the database is CarteModel and the columns are : codcarte-int auto increments, autor-String, imprumut-int, titlu-String
the code that I use to get the data from the data base is:
@SuppressWarnings("unchecked") public List<CarteModel> ListaCarti(){ AnnotationConfiguration conn = new AnnotationConfiguration(); conn.addAnnotatedClass(CarteModel.class); conn.configure(); SessionFactory sesiune = conn.buildSessionFactory(); Session ses = sesiune.getCurrentSession(); ses.beginTransaction(); Query query = ses.createQuery("from CarteModel "); List<CarteModel> lista_c ; lista_c = query.list(); ses.getTransaction().commit(); return lista_c; }
and the code to put the data in the jtable is :
CarteRepository crtrep = new CarteRepository(); CarteTableModel crttblmdl = new CarteTableModel(crtrep.ListaCarte()); CarteController crtctrl = new CarteController();
tableModel = new DefaultTableModel(); table.setModel(crttblmdl); table = new JTable(tableModel); jScrollPane1.setViewportView(table); table.setFillsViewportHeight(true);
please help
|