Search code examples
javahtmlangularjshibernatehql

fetch data from Oracle 11 DB using HQL to show it on a webpage


All of my data for a particular Student is in a Student Table which has StudentId as the primary Key, i am able to get the data in List of StudentObject by using HQL (i am trying to get the list of students who are in say same class) but how should i make a Table on the front-end to display the details of all the students using HTML & AngularJS?


Solution

  • Say you've exposed the serverside API that returns a list of student objects as Json string. you can use the $http service by angular: as documented here: https://docs.angularjs.org/api/ng/service/$http

    $http({
      method: 'GET',
      url: '/someUrl'
    }).then(function successCallback(response) {
        // this callback will be called asynchronously
        // when the response is available
      }, function errorCallback(response) {
        // called asynchronously if an error occurs
        // or server returns response with an error status.
      });
    

    when receiving the response create a simple html table and loop through the students using ng-repeat on your element:

    <tr ng-repeat="student in studentList">
    

    and in the td's u can use {{student.Name}} for example to fetch theuir names or any data you desire:

    <td>{{student.Name}}</td>
    

    hope I've helped, good luck :)