-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Default schema name and named queries
PostPosted: Fri Mar 23, 2007 10:48 am 
Newbie

Joined: Fri Mar 23, 2007 10:27 am
Posts: 1
Location: Poland
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.


Top
 Profile  
 
 Post subject: This thread may help answer your question
PostPosted: Tue Apr 17, 2007 1:58 pm 
Newbie

Joined: Tue Apr 17, 2007 1:56 pm
Posts: 2
Location: Calgary
http://forum.hibernate.org/viewtopic.php?t=956277&start=0&postdays=0&postorder=asc&highlight=&sid=9616986d1e12239619edbda60753b29c


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.