1

I am accessing Postgresql db using hibernate POJO classes and mapping . Now I added a new schema called 'OCS' and not able to generate classes and mapping.Here is my hibernate.cfg.xml

 <property name='hibernate.connection.driver_class'>org.postgresql.Driver</property>
  <property name='hibernate.connection.url'>jdbc:postgresql://test/test_mytest</property>

  <property name='hibernate.connection.username'>username</property>
  <property name='hibernate.connection.password'>password</property>
  <property name='hibernate.connection.pool_size'>10</property>
  <property name='show_sql'>true</property>
  <property name='dialect'>org.hibernate.dialect.PostgreSQLDialect</property>
1
  • You could alter the Postgres user to make ocs its default schema. Commented May 3, 2013 at 18:06

1 Answer 1

4

There are a few ways you can affect the default search path of PostgreSQL:

  1. You can set it globally in the postgresql.conf (add something like search_path=ocs and restart). This is a blunt tool and I don't recommend it.

  2. You can set it on the db. ALTER DATABASE mydb set search_path=ocs This is not a bad option. It restricts it to the database but makes it the default for all applications connecting to the db so may still be too blunt.

  3. You can set it on the user. ALTER USER myuser SET search_path=ocs this does not work so well if the user is connecting to several dbs and many don't have this schema.....

  4. You can set it on the session. After you connect, just send the following SQL: SET search_path=ocs

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.