-->
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.  [ 4 posts ] 
Author Message
 Post subject: Have: Project with hbm.xml files Want:hibernate-search
PostPosted: Thu Apr 03, 2008 7:39 am 
Newbie

Joined: Wed Mar 26, 2008 9:04 am
Posts: 9
Location: Athens, Greece
Hmm, Im probably in trouble but I have to ask anyway.

Went through tons of fields and classes and created xml style mappings for hibernate. Now I want to add hibernate-search annotations.

The reference manual states you can use .hbm.xml mappings but it doesn't actually say you can mix on the same class.

Sooo, if I can have my persistence mapping in xml and my search index annotations as annotation, how would I do it??

My deadline is awfully close PLEASE somebody throw me a lifeline ...

Arne


Last edited by arne1 on Thu Apr 03, 2008 9:12 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 8:27 am 
Hibernate Team
Hibernate Team

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

using xml mapping files together with Hibernate Search annotations should work just fine. The examples in the documentation use annotation to configure your persitence classes, but this is not a requirement.

Just add @Indexed to the classes you want to index. For each indexed class you need at least one @DocumentId and of course you have to annotate all fields you want to end up in the index with @Field.

On top of this you have to add two properties two your hibernate configuration file, namely hibernate.search.default.directory_provider and hibernate.search.default.indexBase.

See also http://www.hibernate.org/hib_docs/search/reference/en/html_single/#d0e137.

Just give it a go and post again in case it does not work.

Good luck.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 8:47 am 
Newbie

Joined: Wed Mar 26, 2008 9:04 am
Posts: 9
Location: Athens, Greece
Hello,

First off all thanks for reading my question and answering.

I have done exactly what you said, but nothing seemed to happen, thats why I got desperate and posted. There is no log4j debug output, no file generated in the directory I gave (tried windows style C:\tmp\lucene and Unix style /c:/tmp/lucene but maybe thats the problem?) but anyway, no error message

Im not quite sure who is actually processing the annotations. I configure using the normal new Configuration().addClass().getSessionFactory() style

Do I need the hibernate-commons-annotation.jar? Currently it seems to run without actually needing it ...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 03, 2008 10:06 am 
Newbie

Joined: Wed Mar 26, 2008 9:04 am
Posts: 9
Location: Athens, Greece
Ok, a few hours into it and the solution is:

Instead of using
Code:
new Configuration().addClass().
.addClass()
.

etc

you have to say
Code:
new AnnotationConfiguration().addClass()
.addClass()

etc

Im not quite sure why this is working, but index files are now created :-)


The hibernate annotation is still in the xml file and is still read,
but now the search annotations are picked up as well.

Arne


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