-->
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.  [ 13 posts ] 
Author Message
 Post subject: CLOB problem
PostPosted: Tue Aug 29, 2017 6:25 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
Hi,

I use Hibernate 5.2.10 and ojdbc8 and try use clob in SQLQuery option.

In hibernate it works, but the Database gives error because a string of more than 4000 characters arrives instead of a clob.

By prepareStatment works by what will not be the OJDBC, Hibernate remains.

Anyone have an idea of what it might be?


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Tue Aug 29, 2017 7:07 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
We have a ClobTest that runs just fine with Oracle and ojdbc8.

Now, there are two situataions for that issue:

1. Either you don't select a Clob column, but a VARCHAR one.
2. Or, you select a Clob as a String so the StringType is used instead of ClobType.

Therefore, you need to add the add:

1. The table schema for the query in question
2. The entity mapping for the table
3. The query that fails


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Tue Aug 29, 2017 7:40 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
We use this code:

Clob clob = hbCtx.getConnection().createClob();
clob.setString(text)
query.setParameter(paramsVal[0], clob, StandardBasicTypes.CLOB);

But try others.

Note:
Query query = createNativeQuery(stringQuery);


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Tue Aug 29, 2017 7:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
What if you try like this:

Code:
Clob clob = session.getLobHelper().createClob(text);
query.setParameter("paramName", clob, StandardBasicTypes.CLOB);


What exactly is the paramsVal[0]? Is it the name of the param or some index?


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Thu Aug 31, 2017 6:34 pm 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
I try this tomorrow.

The paramsVal[0] it's a paramName that we receive in AM array.

Thanks.


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Mon Sep 04, 2017 11:09 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
These code doesn't work. We get the same problem:

Caused by: java.sql.SQLException: ORA-01460


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Mon Sep 04, 2017 11:31 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
In that case, you need to debug your own test and compare it with ours and see why your test does not work while ours works just fine.


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Wed Sep 06, 2017 3:33 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
In your test is used HQL anda I user SqlQuery.

In Query (hql) work fine.


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Wed Sep 06, 2017 6:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
In that case, you can enable JDBC logging, get the query Hibernate executes and use it for your native query.


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Wed Sep 06, 2017 7:06 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
Yes, I user logging and the query is correct.

The problem is that I use a CLOB and setParameter as a ClobType, but when execute in Oracle the type is a VARCHAR2.

When have less than 4000 chars work, when it's bigger give an error.

The problem exist in NativeQuery or SQLQuery (in 4.1) and the JDBC that send a wrong type to DB.


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Wed Sep 06, 2017 7:53 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Quote:
The problem exists in NativeQuery or SQLQuery (in 4.1) and the JDBC that sends a wrong type to DB.


The problem is that 4.x is no longer maintained. Check out if it works with 5.2 or 5.1, and, if it works, then it's time for an upgrade.


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Wed Sep 06, 2017 7:55 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
I have the same problem um 4.1 and the 5.2


Top
 Profile  
 
 Post subject: Re: CLOB problem
PostPosted: Wed Sep 06, 2017 8:01 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
If you can replicate it on 5.2 using our test case templates, then you should open a Jira issue.


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