I am trying to set up a simple Hibernate + Spring JPA repository example in my project. I am using an oracle database, for reference.
I have a simple entity declares as follows
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "item")
public class Item {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private long Id;
private String name;
private String detail;
}
When running the project, hibernate creates a table named hte_item
in oracle.
I have set up a controller which tries to fetch all the items in the table. I have created the following repository
import java.util.List;
import org.springframework.data.repository.CrudRepository;
public interface ItemRepository extends CrudRepository<Item, Long> {
List<Item> findAll();
}
When running itemRepository.findAll
, instead, Spring JPA runs the following query to the database.
select i1_0.id,i1_0.detail,i1_0.name from item i1_0
Which throws an Oracle error ORA-00942: Table or view does not exist
If you notice, the query does not include the prefix generated by Hibernate, which generates the Oracle error. Am I missing something related to configuration here?