2

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:)

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
maks28rus
  • 95
  • 1
  • 1
  • 7
  • Seems a bit odd, typically a database is a rather static thing. What's your usecase / problem? – Jan Groth Jun 16 '15 at 03:37
  • i have several catalogues, which have identical structure tables and I need use one of them on runtime. `calatog1.airports`, `catalog2.airports`, `catalog3.airports` .... – maks28rus Jun 16 '15 at 03:52
  • So disregard my comment. My understanding was that you wanted to access *different* catalogues at runtime. – Jan Groth Jun 16 '15 at 22:17

0 Answers0