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.
-
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.Scott Marlowe– Scott Marlowe2011-06-29 16:07:13 +00:00Commented Jun 29, 2011 at 16:07
-
IT WORKS!!! thank you Scott and thank you Tioma. You have saved my day.Atıfcan Ergin– Atıfcan Ergin2011-06-30 06:48:49 +00:00Commented Jun 30, 2011 at 6:48
-
@fjallstorm : How did you implement 'set search_path = ' in hibernate?Subin Chalil– Subin Chalil2017-08-16 13:53:29 +00:00Commented Aug 16, 2017 at 13:53
Add a comment
|
1 Answer
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
4 Comments
Atıfcan Ergin
It works for hql but It has no effect to methods have native sql queries.
Tioma
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...
Atıfcan Ergin
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.
Tioma
To assign suggestion from Scott, please, see link in the update.