I have my entity called invoice and a column with the name "convenioPago" in the database but cannot find it
try to put @Column (name = "\\"convenioPago\\"", nullable = false)
but still with the same error
@Entity
@Table(name = "invoice", schema = "public")
public class Invoice {
//more columns
@Column (name = "\"convenioPago\"", nullable = false)
private Long convenioPago;
}
I also use @Configuration to create my datasource
@EnableJpaRepositories(basePackages = {"package.repository"})
@Configuration
public class Config {
@Bean
public DataSource dataSource(){
DriverManagerDataSource dataSource = new DriverManagerDataSource();
//use org.postgresql.Driver
}
Note: I use spring-boot-starter-parent 2.1.7.RELEASE
The error I have is: ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR: column invoice0.convenio_pago does not exist
Because it refers to convenio_pago
if it should be to convenioPago
?
If you're using Hibernate native API, then you can escape them using backticks:
@Column(name = "`convenioPago`")
private Long convenioPago;
Thanks @MartinvanWingerden, your comment helped me to the solution! My solution: In my @Configuration, i need this jpaproperties.
Properties jpaProperties = new Properties();
jpaProperties.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.ImplicitNamingStrategy");
jpaProperties.put("hibernate.ejb.physical_naming_strategy","org.hibernate.cfg.PhysicalNamingStrategyImpl");
and the dialect:
jpaProperties.put("hibernate.dialect","org.hibernate.dialect.PostgreSQLDialect");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.