Using Hibernate Increase faculty Min Tuyet\'s salary by 10% Example: hql = \"sel
ID: 3812315 • Letter: U
Question
Using Hibernate Increase faculty Min Tuyet's salary by 10%
Example:
hql = "select p from Person p";
List result = session.createQuery(hql).list();
String toShow = "";
Object[][] tableRow = new Object[result.size()][3];
for (int i = 0; i < result.size(); i++) {
Person thePerson = (Person) result.get(i);
tableRow[i][0] = thePerson.getId();
tableRow[i][1] = thePerson.name;
tableRow[i][2] = thePerson.address;
}
Object[] tableCol = { "ID", "Name", "Address" };
JTable theTable = new JTable(tableRow, tableCol);
JOptionPane.showMessageDialog(null, new JScrollPane(theTable));
session.getTransaction().commit();
person (NAME, ID, ADDRESS, DOB) o faculty (FACULTYID, RANK, SALARY) student (STUDENTID, CLASSIFICATION, GPA, MENTORID, CREDITHOURS) An object-oriented representation is shown as follows. person NAME ADDRE55 DOES ex ends exdends faculty Student RANK CLASSIFICATION GPA CREDITHOURS MENTORS MENTORExplanation / Answer
hql="select p from Person p";
List result = session.createQuery(hql).list();
String toShow = "";
String minTuetId="";
for (int i = 0; i < result.size(); i++) {
Person thePerson = (Person) result.get(i);
if(thePerson.name=="Min Tuyet"){
minTuetId=tableRow[i][0];
break;
}
}
hql2="select f from Faculty f";
List resultFaculty=session.createQuery(hql2).list();
Object[][] tableRowFaculty = new Object[result.size()][4];
for (int j = 0; j < resultFaculty.size(); j++) {
Faculty theFaculty = (Faculty) result.get(j);
tableRow[j][0] = theFaculty.getId();
if(tableRow[j][0]==mintuetId){
theFaculty.salary=theFaculty.salary*.1
}
tableRow[j][1] = theFaculty.rank;
tableRow[j][2] = theFaculty.salary;
tableRow[j][3] = theFaculty.mentors;
}
Object[] tableCol = { "ID", "Rank", "Salary" ,"Mentors"};
JTable theTable = new JTable(tableRow, tableCol);
JOptionPane.showMessageDialog(null, new JScrollPane(theTable));
session.getTransaction().commit();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.