-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Search with clob datatype makes problem
PostPosted: Fri Jun 13, 2008 5:53 am 
Beginner
Beginner

Joined: Mon Oct 01, 2007 8:21 am
Posts: 40
Hi

Im trying with hibernate search functionality, hibernate search is working fine when i index string data type,

My POJO:
Code:

@Entity
@Indexed
public class ConferenceInfo  implements java.io.Serializable {


    @Id
    @DocumentId
     private String conferenceId;
   
    @ContainedIn
     private EventDb eventDb;
   
     private String createdBy;
     private Date dateCreated;
     private String modifiedBy;
     private Date dateModified;
     
     @Field(index=Index.TOKENIZED, store=Store.NO)
     private String theme;
     
     @Field(index=Index.TOKENIZED, store=Store.NO)
     private Clob overview;
     
     @Field(index=Index.TOKENIZED, store=Store.NO)
     private String trackOverview;
     


Im getting the error for the fields overview corresponding to the dataType clob.
Error:
Code:
org.hibernate.search.SearchException: Unable to guess FieldBridge for overview
   at org.hibernate.search.bridge.BridgeFactory.guessType(BridgeFactory.java:180)
   at org.hibernate.search.engine.DocumentBuilder.bindFieldAnnotation(DocumentBuilder.java:321)
   at org.hibernate.search.engine.DocumentBuilder.initializeMember(DocumentBuilder.java:220)
   at org.hibernate.search.engine.DocumentBuilder.initializeMembers(DocumentBuilder.java:167)
   at org.hibernate.search.engine.DocumentBuilder.<init>(DocumentBuilder.java:94)
   at org.hibernate.search.impl.SearchFactoryImpl.initDocumentBuilders(SearchFactoryImpl.java:262)
   at org.hibernate.search.impl.SearchFactoryImpl.<init>(SearchFactoryImpl.java:94)
   at org.hibernate.search.impl.SearchFactoryImpl.getSearchFactory(SearchFactoryImpl.java:172)
   at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:44)
   at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:356)
   at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1304)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
   at com.i3l.sample.test.Example.main(Example.java:60)



As specified in the hibernate search document,
Quote:
Then any property or field can use this bridge thanks to the @FieldBridge annotation

@FieldBridge(impl = PaddedIntegerBridge.class)
private Integer length;


should v write any stringBridge class for the clob and character datatype.

Any suggesstions pls come ahead. I really dont no how to do.

Thanks,
Ambika.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 9:58 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi Ambika,

have you tried to map your overview property like this?

Code:
     @Field(index=Index.TOKENIZED, store=Store.NO)
     @Lob
     private String overview;


Assuming of course that the overview is a string ;-)

If for some reason you have to stick with the Clob type you will have to write your own FieldBridge as described in the Hibernate Search documentation.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 2:53 am 
Beginner
Beginner

Joined: Mon Oct 01, 2007 8:21 am
Posts: 40
Hi Hardy,

for some reason i would like to stick on to CLOB data type for the overview.

I tried like this but still this is not working as such,

Code:
public class ClobImpl implements StringBridge {
   
   public String objectToString(Object object) {
      // TODO Auto-generated method stub
                                System.out.println("Reached objectToString Method===>");
       Clob overview = ( (Clob) object );
       String str = null;
      

try{
       BufferedReader br = new BufferedReader(overview.getCharacterStream());

       String line = null;

       while((line = br.readLine())!= null){

       str.concat(line);

       }

       }catch(SQLException e){

       e.printStackTrace();

       }catch(IOException e){

       System.out.println("");

       e.printStackTrace();

       }

       return overview.toString();

      
   }
}


i tried in the other wy aslo, but still helpless,
Code:
public class ClobImpl implements StringBridge {
   
   public String objectToString(Object object) {
             System.out.println("Reached objectToString Method===>");
      // TODO Auto-generated method stub
                              String Overview = ( (Clob) object ).toString();
                              StringBuilder clobstring = new StringBuilder( );
                              return clobstring .append( Overview ).toString();
                }
}


In my pojo like this,
@FieldBridge(impl = ClobImpl.class)
private Clob overview;

but still i feel the first statement only not reached, the System.out.println("Reached objectToString Method===>");
itself is not printed.

Any idea pls suggest me.

Thanks,
Ambika


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 4:32 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi Ambika,

you still have to have the @Field annotation

ambika_devi wrote:
In my pojo like this,
@FieldBridge(impl = ClobImpl.class)
private Clob overview;

Code:
@Field
@FieldBridge(impl = ClobImpl.class)
private Clob overview;

or like this in one single annotation:
Code:
  @Field(bridge = @FieldBridge(impl = ClobImpl.class.class))
  private Clob overview;


--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 7:47 am 
Beginner
Beginner

Joined: Mon Oct 01, 2007 8:21 am
Posts: 40
Thanks Hardy,

Its Working!


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