1

I have mapped my tables in postgresql 9.0.1 to the spring application with hibernate 3.0 and configured it and it works well on hql queries. But when I try to make native sql query it always want from me to write "schema_name.table_name" like this. Is there any way to introduce the default schema in native sql queries.

3
  • Is this in the default public schema? If not you can set schema search_path like so: set search_path='myschema','public'; and then pgsql will look in myschema then public for any tables you ask for. Commented Jun 29, 2011 at 16:07
  • IT WORKS!!! thank you Scott and thank you Tioma. You have saved my day. Commented Jun 30, 2011 at 6:48
  • @fjallstorm : How did you implement 'set search_path = ' in hibernate? Commented Aug 16, 2017 at 13:53

1 Answer 1

1

Let try set "schema" for mapping if have not. If you use XML it will look like

<class name="class.name" schema="defaut">
...
</class>

UPDATE: There you can found how to set default schema

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

4 Comments

It works for hql but It has no effect to methods have native sql queries.
Just clarify, if you execute the same query in console or by means PgAdmin. In this case you notice the same problem? Probably you must search problem not in hibernate...
I have tested the queries in pgAdmin and got the same error in there. I think I have to make a configuration to database but I have searched everywhere and cannot find a solution.
To assign suggestion from Scott, please, see link in the update.

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.