-->
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.  [ 1 post ] 
Author Message
 Post subject: setParameter(str, Long * is null) is using type VARBINARY
PostPosted: Mon Mar 25, 2013 5:08 pm 
Newbie

Joined: Mon Mar 25, 2013 4:45 pm
Posts: 1
Short version, using a native query with setParameter passing a null Long object, the framework seems to be mapping this null value to a VARBINARY type instead of a number, causing an oracle error... long version below

I have some code (JPA w/hibernate3.3.2) that generates a native query that includes something akin to:

... LEFT OUTER JOIN table2 tb2 ON tb2.id = :table2ID ...
where (tb2.id is Number(12))

and Java code:

Code:
public List<ResultVO> exec(Long tb2ID, ...)
return this.em
      .createNativeQuery(MyClass.SQL, ResultVO.class)
      .setParameter("table2ID", tb2ID)
      .getResultList();


(Its a relatively long query, and private to a financial company, so sorry for the obfuscation...)

In the logs I get:
ORA-00932: inconsistent datatypes: expected NUMBER got BINARY

When I enabled jdbc logging in weblogic, I noticed that it was doing this behind the scenes:
<[weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_OraclePreparedStatementWrapper@6f] setNull(1, -3)>
Which explains the issue as Types.VARBINARY is -3.

Not sure how to fix this short of changing the query to conditionally include "null" or ":param" in the SQL string, and then only setting the parameter if the Long is not null, which I would prefer not to do...

Any thoughts? Thanks.


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

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.