-->
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.  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 5:30 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
Hello i have got one question

I Need indexes only one class no other i use jboss ver 4.2 GA , hibernate-search-3.4.0.Final.jar, lucene-core-3.3.0.jar.

i have got a case something like that:
Code:
@MappedSuperclass
@Inheritance(strategy=InheritanceType.JOINED)
public abstract Class User implements Serializable, Cloneable
{
   private static final long serialVersionUID = 1L;

   @Id
   @GeneratedValue(strategy=GenerationType.IDENTITY)
   @DocumentId
   private long id;

        @Field(store=Store.YES)
   private String description;

        @Field
   private String name;

        //other stuff
}

and:

@Indexed
private Class Person Extend User implements Serializable, Cloneable
{
       @OneToMany
   @JoinColumns({
      @JoinColumn(name="albumId", referencedColumnName="id")
   })
   @IndexedEmbedded
   private List<Photo> photos;

      @OneToMany
   @JoinColumns({
      @JoinColumn(name="id", referencedColumnName="id")
   })
   private List<Buy> buy;
        //other stuff
}

@Indexed
public class Photo implements Serializable, Cloneable
{
        @Id
   @GeneratedValue(strategy=GenerationType.IDENTITY)
   @DocumentId
   private long id;

        @Field
        private String name;
}



and jboss give me errror Reason: java.lang.annotation.IncompleteAnnotationException: org.hibernate.search.annotations.Field missing element index

Depends On Me:
jboss.j2ee:jar=person-app.jar,name=PersonEntityHandler,service=EJB3

I need only indexed field in class Person and photo not Buy


And i have one more question:
in book HIbernate Search in Action on page 38 they wrote:

Quote:
<hibernate-configuration>
<session-factory>
...
<event type="post-update">
<listener
class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-insert">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-delete">
<listener class="org.hibernate.search.event.FullTextIndexEventListener"/>
</event>
<event type="post-collection-recreate">
<listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
</event>
<event type="post-collection-remove">
<listener
class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
</event>
<event type="post-collection-update">
<listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
</event>
</session-factory>
</hibernate-configuration>



and i wrote in persistance.xml

Code:
<property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
        <!-- directory where the indexes will be stored -->
        <property name="hibernate.search.default.indexBase" value="/usr/local/storage/index"/>
        
        <property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.ejb.event.post-update"  value="org.hibernate.search.event.FullTextIndexEventListener"/>
         <property name="hibernate.ejb.event.post-delete"  value="org.hibernate.search.event.FullTextIndexEventListener"/>


but if i use property :
Code:
<property name="hibernate.ejb.event.pre-collection-update" value="org.hibernate.search.event.FullTextIndexCollectionEventListener"" />
   <property name="hibernate.ejb.event.pre-collection-remove"  value="org.hibernate.search.event.FullTextIndexCollectionEventListener"" />
   <property name="hibernate.ejb.event.post-collection-recreate"  value="org.hibernate.search.event.FullTextIndexCollectionEventListener"" />


I have got error in Jboss that this property dont exist ??


Last edited by lukasw44 on Wed Jul 20, 2011 11:09 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 6:26 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello,
Hibernate Search 3.4.x requires a much newer version of Hibernate Core than what is contained in JBoss 4.2 ( it needs a 3.6.x instead of a 3.2.x ).
Also in that version of JBoss version the hibernate-annotations.jar was containing a preview of Hibernate Search, so some of the annotations are in that jar and are conflicting with the newer version you have deployed.

You should either use an older version of Search (from the 3.0.x series) or update the Hibernate versions in the application server by replacing all hibernate related jars with newer editions by downloading the 3.6.x distribution.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 6:31 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
One more thing:
when using Hibernate Search 3.4 you don't need to register any event listener, they are picked up automatically. No configuration property is required at all, all you have to do is add search to the classpath, and add annotations; you still likely want to configure the path to store the indexes and other performance tuning settings, but none are required.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 6:34 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
Its working

i add @Field(index=Index.TOKENIZED)

but in api:

public abstract Index index

Returns:
Returns a Index enum defining how the value should be indexed. Defaults to Index.TOKENIZED.

Default:
org.hibernate.search.annotations.Index.TOKENIZED

And i must add @Index into Abstract class

in Hibernate in Action page 72:
@Indexed only when:
You want to be able to search by this entity.

The entity is of a concrete type (not abstract).


Ok its old version Jboss but i cant update hibernate core and hibernate annotation to the new version (i am only developer :/ and i must use this jboss version)

Thanks for reply


Last edited by lukasw44 on Wed Jul 20, 2011 6:49 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 6:44 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
s.grinovero wrote:
One more thing:
when using Hibernate Search 3.4 you don't need to register any event listener, they are picked up automatically. No configuration property is required at all, all you have to do is add search to the classpath, and add annotations; you still likely want to configure the path to store the indexes and other performance tuning settings, but none are required.


When i delete :
<property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>
<property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/>
<property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/>

i have not got indexes in directory ??

And i must store indexes in directory, not in RAM


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 6:48 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Ok its old version Jboss but i cant update hibernate core and hibernate search to the new version (i am only developer :/ and i must use this jboss version)

Actually I said that you're using a version of Hibernate Search which is too new, you need an older version to be compatible with that older JBoss: take version 3.0.1.

Quote:
When i delete :
<property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>
<property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/>
<property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/>

i have not got indexes in directory ??

Ok that means the new version of Hibernate Search was not picked up - and that's right since you have an old version of core - but still the new version on the classpath is creating conflicts in classes.
I'd recomment you to use Tattletale to scan for class duplicates.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 6:51 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
Thanks for reply i use older version


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 7:18 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
I have got one more question

And how version lucene-core.jar i need use
in Jboss4.2GA and hibernate-search3.01.jar ??


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 7:20 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
the one contained in the distribution: https://sourceforge.net/projects/hibern ... /3.0.1.GA/

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 7:26 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
but i need to use luceneQuery

Code:
QueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_CURRENT , personField, new StandardAnalyzer(Version.LUCENE_CURRENT));
         
      org.apache.lucene.search.Query luceneQuery;
      
      try{
         luceneQuery = queryParser.parse(query);
      } catch (Exception e)
      {
         System.out.println("Lucene query exception !");
         return null;
      }
               
      
      System.out.println("LUCENE QUERY:  "  + luceneQuery.toString());      
      
      FullTextEntityManager ftem =  org.hibernate.search.jpa.Search.createFullTextEntityManager(entityManager);
              Query jpaQuery = ftem.createFullTextQuery(luceneQuery, Album.class);
      
      jpaQuery.setFirstResult(min);
      jpaQuery.setMaxResults(max);
      
      return (List<Album>) jpaQuery.getResultList();


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 7:34 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
please take a minute to try out what I'm recommending you. I gave you a download link containing the compatible Lucene version, you could have found it yourself, and I don't think you tried it in 5 minutes time. So how is your last post related, is it a question?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 7:41 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
No my question is how can i use luceneQuery with hibernate-search3.01

because before i use lucene-core3.30 and hibernate-search3.4.0

now i use only hibernate-search3.0.1 and i not found method :
Code:
QueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_CURRENT , albumField, new StandardAnalyzer(Version.LUCENE_CURRENT));
         
      org.apache.lucene.search.Query luceneQuery;



So my question is how can i use this lucene with this version hibernate-search3.0.1.jar ??

you wrote I gave you a download link containing the compatible Lucene version

so i dont know how to use lucene in search ?

When i test this query i have got exception
Code:
javax.ejb.EJBException: java.lang.RuntimeException: java.lang.NoSuchMethodError: org.hibernate.search.FullTextSession.createFullTextQuery(Lorg/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hibernate/search/FullTextQuery;; nested exception is: java.lang.RuntimeException: java.lang.NoSuchMethodError: org.hibernate.search.FullTextSession.createFullTextQuery(Lorg/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hibernate/search/FullTextQuery;
java.lang.RuntimeException: java.lang.NoSuchMethodError: org.hibernate.search.FullTextSession.createFullTextQuery(Lorg/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hibernate/search/FullTextQuery;


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 7:45 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
ah, now I understand.
That older version had a slightly different API, the Version parameters should be removed.

Read the relevant documentation for some examples: the pdf containing the docs for each specific version is bundled in the distribution.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 8:21 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
I use lucene-core ver 2.3
with hibernate-search 3.0.1

and i have got the same problem
Code:
avax.ejb.EJBException: java.lang.RuntimeException: java.lang.NoSuchMethodError: org.hibernate.search.FullTextSession.createFullTextQuery(Lorg/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hibernate/search/FullTextQuery;; nested exception is: java.lang.RuntimeException: java.lang.NoSuchMethodError: org.hibernate.search.FullTextSession.createFullTextQuery(Lorg/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hibernate/search/FullTextQuery;
java.lang.RuntimeException: java.lang.NoSuchMethodError: org.hibernate.search.FullTextSession.createFullTextQuery(Lorg/apache/lucene/search/Query;[Ljava/lang/Class;)Lorg/hibernate/search/FullTextQuery;


now i have
got
Code:
QueryParser queryParser = new MultiFieldQueryParser(albumField, new StandardAnalyzer());
   
org.apache.lucene.search.Query luceneQuery;


i have been read that hibernate search 3.0.1 support of Lucene 2.3 (performance improvements and stability)
what i do wrong ??


Top
 Profile  
 
 Post subject: Re: [Hibernate Search] Indexes only one classes
PostPosted: Wed Jul 20, 2011 9:42 am 
Beginner
Beginner

Joined: Wed Jul 20, 2011 5:07 am
Posts: 23
its working fine when i replace jar in jboss

hibernate-annotations.jar (3.3.x for Search 3.0)
* hibernate-validator.jar (3.0.x for Search 3.0)
* hibernate-entitymanager.jar (3.3.x for Search 3.0)
* hibernate-commons-annotations.jar (3.0.x for Search 3.0)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 22 posts ]  Go to page 1, 2  Next

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.