-->
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.  [ 4 posts ] 
Author Message
 Post subject: Stopping table alias on discriminator formula
PostPosted: Wed Jun 21, 2006 3:24 am 
Beginner
Beginner

Joined: Sun Oct 09, 2005 3:21 pm
Posts: 40
Hibernate version: 3.1.2

Name and version of the database you are using: DB2 9.0 (Viper)

Problem: Basically I want to use a formula in the discriminator element with a new DB2 function with DB2 9.0 (Viper) to subclass based on data in an XML column. The problem is that Hibernate adds table aliases even to keywords (see below):

Code:
(Mapping document)
<class ....>
   ...

   <discriminator formula="xmlcast(xmlquery('$d/mbean/@typ' passing XMLDATA as &quot;d&quot;) AS VARCHAR(50))"/>

   ...
</class>


Get translated to:
Code:
(Generated SQL)
... where xmlcast (xmlquery('$d/mbean/@typ' this_.passing this_.XMLDATA as this_."d") AS VARCHAR(50))='miljö' ...



Is there some way to keep the qualifiers off certain keywords (i.e. passing/"d")? / Matthew


Top
 Profile  
 
 Post subject: Editing Template class
PostPosted: Wed Jun 21, 2006 5:15 am 
Beginner
Beginner

Joined: Sun Oct 09, 2005 3:21 pm
Posts: 40
Seems I might have to edit the org.hibernate.sql.Template class to include the keyword passing and except " as a quote token. Or is there another way through Hibernate properties in the mapping document?

If I have to edit Template then handling the passing keyword isn't problem but dealing with double quotes as a token might be. After looking at the Template class I am not sure why double quotes don't get left alone?


/ Matthew


Top
 Profile  
 
 Post subject: extending DB2Dialect
PostPosted: Wed Jun 21, 2006 7:34 am 
Beginner
Beginner

Joined: Sun Oct 09, 2005 3:21 pm
Posts: 40
Have extended the DB2Dialect and added keywords plus xmlcast/xmlquery functions:

Code:
import org.hibernate.dialect.DB2Dialect;

import org.hibernate.dialect.function.StandardSQLFunction;

public class MatrixDialect extends DB2Dialect {

   public MatrixDialect() {
      super();
      registerFunction("xmlcast", new StandardSQLFunction("xmlcast") );
      registerFunction("xmlquery", new StandardSQLFunction("xmlquery") );
     
      registerKeyword("passing");
   }

}


But still not able to handing double quotes around xmlquery variables. Any ideas? Just need somebody to get me over the hump. / Matthew


Top
 Profile  
 
 Post subject: Added open/closeQuote
PostPosted: Wed Jun 21, 2006 8:32 am 
Beginner
Beginner

Joined: Sun Oct 09, 2005 3:21 pm
Posts: 40
Until I find a better solution I have added the following to MatrixDialect:

Code:
   public char openQuote()
   {
      return '!';
   }

   public char closeQuote()
   {
      return '!';
   }



But would rather update the tokens which are automatically ignored. / matthew


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