-->
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: Read text stored in Oracle Blob column
PostPosted: Thu Oct 01, 2009 8:07 am 
Newbie

Joined: Thu Oct 01, 2009 7:47 am
Posts: 1
Hi

i need to fetch the Blob from the oracle data base.
we have stored the text string in it.i want to read it in java.
Please help me regarding the issue.

I have done the following to query the data from oracle using HQL.

Mapped the table columns i need.
contact.hbm.xml

<class name=""roseindia.tutorial.hibernate.Contact"" table="CONTACT">
<id name="transaction_id" type="long" column="TRANSACTION_ID" >
<generator class="assigned"/>
</id>

<property name="additional_info" type="binary">
<column name="ADDITIONAL_INFO" sql-type="blob"/>
</property>
</class>

Class file for java object
import java.sql.Blob;
public class Contact {

private Blob additional_info;

public Blob getAdditional_info() {
return additional_info;
}
public void setAdditional_info(Blob additional_info) {
this.additional_info = additional_info;
}
}

HQL QUERY
List Contact = session.createSQLQuery("select {ins.*} from Contact ins ").addEntity("ins",Contact).list();

for (Iterator it = Contact.iterator(); it.hasNext();)
{
Contact contactObject = (Contact) it.next();
System.out.println("ID: " + contactObject.getAdditional_info());
}


Out Put:
ID:[B@458f41
ID:[B@1f01a29

I am getting following output.please tell me how i can read the text.


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.