Here are my spring data jpa properties at connection configuration level in application.properties
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.url=jdbc:mysql://host:3306/schema1?useSSL=false
spring.datasource.username=username
spring.datasource.password=password
All entities by default look for tables in schema1 However, I have another schema2 present at the same host for which I want an entity to map to
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Entity
@Table(name = "table1",schema = "schema2")
public class Entity1 implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name="id")
private long id;
//some columns
}
I have defined a repository for this entity as follows:
@Repository
public interface Entity1Repository extends JpaRepository<Entity1, Long> {
//some methods
}
However jpa is still looking for table1
in schema1
despite it being clearly annotated as schema2 at the @Table
annotation in the entity level.
What am i missing here?