Hi,
I found that schema name (from nhibernate configuration file or from attribute of hibernate-mapping root) does not work for named sql queries.
I have to prefix objects with schema names in these queries.
I connect to db to work on another schema name (so from different user than the schema owner).
Database: Oracle 10g Express Edition (10.2.0.1.0)
NHibernate: 1.2.0 RC1
Part of hibernate.cfg.xml file:
Code:
<property name="hibernate.connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="hibernate.connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
<property name="hibernate.connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
<property name="hibernate.dialect">NHibernate.Dialect.Oracle9Dialect</property>
...
<property name="hibernate.default_schema">my_schema</property> <!-- does not work for sql named queries -->
Part of embedded resource file:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="..." assembly="..." schema="my_schema"> <!-- schema attribute does not work-->
<sql-query name="SequenceNextVal" >
<return-scalar column="Id" type="Int64" />
<![CDATA[
SELECT my_sequence.nextval as Id FROM DUAL
]]>
</sql-query>
</hibernate-mapping>
I must change the select statement above to "SELECT my_schema.my_sequence.nextval as Id FROM DUAL" in order for it to work.
Question: Working as design or bug?
I have to use the sequence this way. I work with legacy data with composite keys and can't just use
Code:
<generator class="sequence"><param name="sequence">my_sequence</param></generator>
BTW Above <generator> does not work without explicit adding the schema name in a hibernate-mapping root node. I mean schema option from config or class node does not work but the same option per mapping file works fine.
I've searched the forum and found this without any replies:
http://forum.hibernate.org/viewtopic.php?t=967614&highlight=query+schema
Thanks for any answer.