Reputation: 5317
Hi in my spring boot postgresql application, when i retrieve all record using DAO it show column does not exists.
ERROR
WARN : org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 42703
ERROR: org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ERROR: column merchantit0_.id does not exist
Position: 8
ERROR: org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/customerplus].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [/customerplus] 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
org.postgresql.util.PSQLException: ERROR: column merchantit0_.id does not exist
Position: 8
Entity Domain
@Entity
@Table(name = "merchant_item_category")
public class MerchantItemCategory{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false, length = 11)
private long id;
@ManyToOne
@JoinColumn(name = "merchant_id", nullable = false)
private Merchant merchant;
// getters and setters
}
DAO
public List<MerchantItemCategory> getAllMerchantItemCategoryByMerchantId(long id) {
Session session=getSession();
List<MerchantItemCategory>itemCategories=session.createQuery("from MerchantItemCategory where merchant.id=:merchantId and isDelete='0' order by categoryName asc")
.setParameter("merchantId", id)
.list();
return itemCategories;
}
I just checked every object and it is correct, But how this error occurring..!
Upvotes: 1
Views: 5831
Reputation: 41
A potential cause of this error is when you haven't defined the hibernate "default schema" property.
I fixed this issue by adding line below to my application.properties:
spring.jpa.properties.hibernate.default_schema=${your-default-schema-name}
Upvotes: 4