I have a table:
CREATE TABLE airports (
id SERIAL PRIMARY KEY,
name VARCHAR2 NOT NULL,
);
have this class for mapping:
@Entity(name = "AirportEntity")
@Table(name = "airports", schema = "public", catalog = "postgres")
public class AirportsEntity {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Basic
@Column(name = "name")
private String name;
/* getter and setter */
}
How can I set catalog = "postgres"
on run time? I want catalog = parameter
, where parameter
set on run time.
PS. I deleted schema = "public", catalog = "postgres"
on table annotation and in hibernate.cfg.xml
set <property name="hibernate.connection.url"></property>
at run time,
(configuration.getProperties().setProperty("hibernate.connection.url", "jdbc:postgresql://" + ip + ":" + port + "/"+ catalog);
) and all work:)