title: could not extract result set: hibernate, SQL grammar exception in oracle database
body: <p>Please help me to solve this problem. This is the stack trace of my error.</p>
  <blockquote>
  <p>Servlet.service() for servlet [dispatcherServlet] in context with path
  [] threw exception [Request processing failed; nested exception is
  org.springframework.dao.InvalidDataAccessResourceUsageException: could
  not extract ResultSet; SQL [n/a]; nested exception is
  org.hibernate.exception.SQLGrammarException: could not extract
  ResultSet] with root cause</p>
  <p>oracle.jdbc.OracleDatabaseException: ORA-00942: table or view does not
  exist</p>
  </blockquote>
  <p>This is the employee.java class.</p>
  <pre><code>package com.example.demo.model;
  
  
  import javax.persistence.*;
  import java.io.Serializable;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  
  @Entity
  @Table(name = &quot;demo_employee1&quot;)
  
  public class Employee implements Serializable {
  
  
      private static final long serialVersionUID = 2L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;s_employeeCreate&quot;)
      @SequenceGenerator(name = &quot;s_employeeCreate&quot;, sequenceName = &quot;s_employeeCreate&quot;, allocationSize = 1)
      @Column(name = &quot;id&quot;, unique = true, nullable = false)
      private Long id;
  
  
      @Column(name = &quot;first_name&quot;)
      private String firstName;
  
      @Column(name = &quot;last_name&quot;)
      private String lastName;
  
      @Column(name = &quot;email_address&quot;)
      private String email;
  
      @Column(name = &quot;employee_DepartmentId&quot;)
      private String employeeDepartmentId;
  
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
  
      }
  
      public String getEmployeeDepartmentId() {
          return employeeDepartmentId;
      }
  
      public void setEmployeeDepartmentId(String employeeDepartmentId) {
          this.employeeDepartmentId = employeeDepartmentId;
      }
  
  
  }
  </code></pre>
  <p>This is the EmployeeDTO.java</p>
  <pre><code>package com.example.demo.DTO;
  
  import com.fasterxml.jackson.annotation.JsonProperty;
  
  import com.example.demo.model.Employee;
  
  import org.springframework.beans.BeanUtils;
  
  public class EmployeeDTO {
  
      @JsonProperty(value=&quot;id&quot;)
      private long id;
  
      @JsonProperty(value=&quot;firstName&quot;)
      private String firstName;
  
      @JsonProperty(value=&quot;lastName&quot;)
      private String lastName;
  
  
      @JsonProperty(value=&quot;email&quot;)
      private  String email;
  
  
      @JsonProperty(value=&quot;employeeDepartmentId&quot;)
      private String employeeDepartmentId;
  
  
  
      public String getFirstName()
      {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName()
      {
          return lastName;
      }
  
      public void setLastName(String lastName)
      {
          this.lastName = lastName;
      }
      public  String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getEmployeeDepartmentId(){
          return employeeDepartmentId;
      }
  
      public void setEmployeeDepartmentId(String employeeDepartmentId){
          this.employeeDepartmentId= employeeDepartmentId;
      }
  
  
      public static Employee valueOf(EmployeeDTO employee) {
          if (employee != null) {
              Employee employee1 = new Employee();
  
  
              employee1.setFirstName(employee.getFirstName());
              employee1.setLastName(employee.getLastName());
              employee1.setEmail(employee.getEmail());
              employee1.setEmployeeDepartmentId(employee.getEmployeeDepartmentId());
  
  
  
  
              return employee1;
          }
          return null;
      }
  
  
   public static EmployeeDTO valueOf(Employee employee) {
          EmployeeDTO employeeDTO = new EmployeeDTO();
          BeanUtils.copyProperties(employee, employeeDTO);
          return employeeDTO;
      }
  
      public static Employee valueOf1(EmployeeDTO employeeDTO) {
          Employee employee = new Employee();
          BeanUtils.copyProperties(employeeDTO, employee);
          return employee;
      }
      @Override
      public String toString() {
          return &quot;EmployeeDTO{&quot; +
  
                  &quot; firstName='&quot; + firstName + '\'' +
                  &quot;, lastName='&quot; + lastName + '\'' +
                  &quot;,email='&quot;+ email+'\''+
                  &quot;, EmployeeDepartmentId=&quot; + employeeDepartmentId +
                  '}';
      }
  
  
  }
  </code></pre>
  <p>This is the EmployeeService.java class.</p>
  <pre><code>package com.example.demo.Service;
  
  import com.example.demo.model.Employee;
  import com.example.demo.DTO.EmployeeDTO;
  import com.example.demo.Repositry.EmployeeRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.BeanUtils;
  
  import org.springframework.stereotype.Service;
  
  import java.util.List;
  import java.util.ArrayList;
  import org.springframework.util.CollectionUtils;
  
  
  import java.util.Optional;
  
  
  @Service
  public class EmployeeService {
  
      @Autowired EmployeeRepository employeeRepository;
  
      @Autowired EmployeeService employeeService;
  
      Logger LOG = LoggerFactory.getLogger(EmployeeService.class);
  
      public Employee createEmployee(EmployeeDTO employeeDTO) {
          LOG.info(employeeDTO.toString());
          Employee employee = EmployeeDTO.valueOf1(employeeDTO);
          LOG.info(employee.toString());
          return employeeRepository.saveAndFlush(employee);
      }
  
      public EmployeeDTO getUserById(Long id) {
          Employee employee = employeeRepository.findById(id).orElse(null);
          if (employee != null) {
              return EmployeeDTO.valueOf(employee);
          }
          return null;
      }
  
      public List&lt;EmployeeDTO&gt; getAllUsers() {
          List&lt;Employee&gt; employees = employeeRepository.findAll();
          List&lt;EmployeeDTO&gt; employeeDTOList = new ArrayList&lt;&gt;();
          if (!CollectionUtils.isEmpty(employees)) {
              for (Employee employee: employees) {
                  employeeDTOList.add(EmployeeDTO.valueOf(employee));
              }
          }
          return employeeDTOList;
      }
  
  
  }
  </code></pre>
  <p>This is the EmployeeController.java class</p>
  <pre><code>@Controller
  public class EmployeeController {
      Logger LOG = LoggerFactory.getLogger(EmployeeController.class);
  
  
   @Autowired
      private EmployeeService employeeService;
  
      @RequestMapping(value = &quot;/test&quot;, method = RequestMethod.GET)
      @ResponseBody
      public String testApi() {
          return &quot;Hello World&quot;;
      }
  
      @RequestMapping(value = &quot;/employee/create&quot;, method = RequestMethod.POST)
      @ResponseBody
      public String createEmployee(@RequestBody EmployeeDTO employeeDTO) {
          LOG.info(&quot;create Employee&quot;);
          Employee employee = employeeService.createEmployee(employeeDTO);
          if (employee != null) {
              return &quot;Successfully created user with &quot; + employee.getFirstName() + &quot; &quot; + employee.getLastName();
          }
          return &quot;Failed to create user&quot;;
      }
  
      @RequestMapping(value = &quot;/user/read&quot;, method = RequestMethod.GET)
      @ResponseBody
      public EmployeeDTO getUser(@RequestParam Long id) {
          LOG.info(&quot;get user&quot;);
          return employeeService.getUserById(id);
      }
  
    
  
        @RequestMapping(value = &quot;/user/all&quot;, method = RequestMethod.GET)
          @ResponseBody
          public List&lt;EmployeeDTO&gt; getAllUsers() {
              LOG.info(&quot;get all users&quot;);
              return employeeService.getAllUsers();
          }
      }
  </code></pre>