I am using the following model classes:
@Entity
@Table(name = "TableA")
public class TableA {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, name="Id")
private BigInteger id;
@OneToOne
@JoinColumn(name = "Id", referencedColumnName = "Id")
private TableB tableB;
//Setters Getters
}
@Entity
@Table(name = "TableB")
public class TableB {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, name="Id")
private BigInteger id;
//Setters Getters
}
Then the following interface and controller to create the corresponding db records:
public interface TableARepository extends CrudRepository<TableA, BigInteger>{}
@Transactional(rollbackFor = Exception.class)
@PostMapping(value="/CreateTableA")
public void createTableA(@RequestParam String something){
TableB tableB = new TableB();
TableA tableA = new TableA();
tableA.setTableB(tableB);
TableARepository.save(tableA);
}
I have also declared my schema at the application.properties file
spring.jpa.properties.hibernate.default_schema=public
I get the following error:
org.postgresql.util.PSQLException: ERROR: relation "public.tableA" does not exist
CodePudding user response:
try adding below line to your application.properties file
spring.jpa.hibernate.ddl-auto=update
CodePudding user response:
Try adding these in your application.properties:
spring.jpa.hibernate.ddl-auto=update
and remove this:
spring.jpa.properties.hibernate.default_schema=public
as you don't need to mention if it is public.
CodePudding user response:
To resolve this issue, do as follows:
Remove Schema Name from the JDBC Connection String (JDBC driver for PostgreSQL does not support Schema).
Verify the database for conflicting Schema/Table Name and rename the same (Case Sensitive).
For instance, having two schemas 'Mobile' and 'mobile' on the database would result in this error.
you can also refer this : PSQLException: ERROR: relation "TABLE_NAME" does not exist