hibernate-reactive icon indicating copy to clipboard operation
hibernate-reactive copied to clipboard

There is no possibility to establish a connection to the Postgress cluster

Open Dem1616 opened this issue 6 months ago • 0 comments

Hibernate reactive 3.0, vertx 4.5.14. When specifying multiple hosts in the connection string along with the parameter targetServerType=master, the connection pool is not created

    public Mutiny.SessionFactory getSessionFactory(@Qualifier("VertxMain") Vertx vertx) {
        Properties hiberProps = new Properties();
        hiberProps.put("jakarta.persistence.jdbc.url", "jdbc:postgresql://host1:5433,host2:5433/db?targetServerType=master");
        ...
        org.hibernate.cfg.Configuration cfg = new org.hibernate.cfg.Configuration();
        ...
        cfg.addProperties(hiberProps);

        Mutiny.SessionFactory sessionFactory =
                cfg.buildSessionFactory(new ReactiveServiceRegistryBuilder().applySettings(cfg.getProperties()).build())
                       .unwrap(Mutiny.SessionFactory.class);
        
        return sessionFactory;
    }

In such a configuration, the connection pool is not created: Cannot invoke "io.vertx.sqlclient.Pool.getConnection()" because "pool" is null In the interface SqlClientPoolConfiguration, the method connectOptions accepts a parameter of type URI, which comes from the setting jakarta.persistence.jdbc.url and assumes parsing only a single host value from the connection string.

How can I achieve a similar connection behavior in Hibernate Reactive as in Hibernate ORM, so that the connection is made specifically to the host that acts as a master in the cluster?

Dem1616 avatar Jun 02 '25 15:06 Dem1616