-->
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: System Key to Hexadecimal
PostPosted: Tue Aug 26, 2008 4:32 am 
Newbie

Joined: Mon Jul 28, 2008 9:11 am
Posts: 2
Hi

I am using hibernate to retrieve data from a db2 database on a mainframe. The problem I have is with the System key. The System Key when retrieved from the database is not readable with square boxes for character I think java does not recognize. But when I query using this system (e.g. where systemKey =) I get the right data I want back. This is fine as I don’t need the System Key to display, only to query or as a foreign key. The question I am asking is will Java or Hibernate ever try to change the retrieve value of System Key (the character it does not recognize) special when the System Key is first retrieved.

My second question is that I can retrieve the hexadecimal value of the System Key by using the query e.g. select HEX(c.customerId). But I can’t retrieve data in the where clause using a HEX value, as in db2, you would normally use X, e.g. from Customer as c where c.customerId= X'F1F0F0F0F0F0F0F1'. This does not seem to work in Hibernate, so can someone please tell me how to change the hexadecimal value to a System Key in a query in hibernate.

Thanks Pritesh


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 26, 2008 4:55 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Your second question can maybe be solved by registering a custom SQLFunction with Hibernate. To do this you need to access the Configuration object when your application is starting. Something like this may work, but I don't know the corresponding Type for the SystemKey.

Code:
Configuration c = ...
SQLFunctionTemplate x = new SQLFunctionTemplate(typeOfSystemKey, "X?1");
c.addSqlFunction("x", x);


After this you should be able to do:

Code:
from Customer as c where c.customerId= x('F1F0F0F0F0F0F0F1')


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.