-->
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.  [ 3 posts ] 
Author Message
 Post subject: <Map> and custom SQL (sql-insert etc) - NHibernate 1.2
PostPosted: Mon Feb 26, 2007 10:22 am 
Newbie

Joined: Mon Feb 26, 2007 10:09 am
Posts: 2
Does the <map> element support custom SQL. Can I not put a <sql-insert> element in it?

I've looked at the nhibernate-mapping.xsd and it shows that <sql-insert> is a valid child of <map>.

However when I try to use it I get an error:

Code:
XML validation error: The element 'map' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'sql-insert' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'urn:nhibernate-mapping-2.2:meta urn:nhibernate-mapping-2.2:jcs-cache urn:nhibernate-mapping-2.2:cache urn:nhibernate-mapping-2.2:key'.


Which says quite clearly that is it not..... Am I missing something obvious? I really dont want to have to use an "INSTEAD OF" trigger. (I need to do this as NHibernate is updating a field in the view that is read-only)


Here is my mapping file
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="Test,Base" table="Test">
      <id name="Id" column="tstId" type="Int32" unsaved-value="0">
         <generator class="native"/>
      </id>
      ...
      <map name="Parameters" table="vwTestInfo" lazy="false" inverse="false" cascade="all" >
         <sql-insert>
            insert into ....
         </sql-insert>
      </map>
   </class>



Thanks

Andre


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 26, 2007 10:51 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
AFAIR, you have to define all the standard stuff in <map> first, and after that you can specify the custom SQL.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 2:18 pm 
Newbie

Joined: Mon Feb 26, 2007 10:09 am
Posts: 2
sergey wrote:
AFAIR, you have to define all the standard stuff in <map> first, and after that you can specify the custom SQL.


Hi Sergey,

Are you saying that I can use sql-insert etc as the last elements in the map element? Because that does not seem to work either :(

i.e.

Code:
<map>
<key column="parentId"/>
   <index column="paramName" type="String"/>
   <composite-element class="..">
   </composite-element>
   <sql-insert>
      ...
   </sql-insert>


I still get the same error....

Is there perhaps an example somewhere of using custom SQL with a map?

Thanks again.[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.