-->
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: Beginner hibernate / spring / hiberante-search question
PostPosted: Tue Feb 15, 2011 7:42 am 
Newbie

Joined: Tue Nov 09, 2010 12:45 pm
Posts: 7
Hi,

I am sure this is a fairly simple question but I can't seem to phrase it in a way google can help.

In the hibernate-search docs there is a programmatic API (http://docs.jboss.org/hibernate/search/3.2/reference/en-US/html/search-mapping.html#hsearch-mapping-programmaticapi),

I am trying to create a search mapping as per :
Code:
SearchMapping mapping = new SearchMapping();
[...]
configuration.setProperty( Environment.MODEL_MAPPING, mapping );


But I dont really understand what the configuration object is and how i would obtain it. I am using spring and the org.springframework.orm.hibernate3.support.HibernateDaoSupport package for my DAO so is it something I need to inject somehow in the form of a bean? I will pop this on a spring forum as well as it might be more spring related.

Any help and suggestions would be much appreciated.

Spring setup is here is it is useful, if other code would help just let me know
Code:
   <bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      

         <property name="annotatedClasses">
            <list>
      
              <value>com.ActivityGB.client.domain.Provider</value>
              <value>com.ActivityGB.client.domain.Activity</value>
              <value>com.ActivityGB.client.domain.Location</value>
              <value>com.ActivityGB.client.domain.Address</value>
              <value>com.ActivityGB.client.domain.Category</value>
            </list>
      
       </property>
       
      <property name="mappingResources">

         <list>

            <value>com/ActivityGB/client/domain/Provider.hbm.xml</value>
            ....
            <value>com/ActivityGB/client/domain/UserWall.hbm.xml</value>
            


         </list>
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.bytecode.provider">cglib</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.format_sql">true</prop>
            <!-- <prop key="hibernate.use_sql_comments">true</prop> -->
            <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
            <prop key="hibernate.jdbc.batch_size">20</prop>

            <prop key="hibernate.c3p0.min_size">10</prop>
            <prop key="hibernate.c3p0.max_size">100</prop>
            <prop key="hibernate.c3p0.timeout">10</prop>
            <prop key="hibernate.c3p0.acquireRetryAttempts">30</prop>

            <prop key="hibernate.c3p0.acquireIncrement">5</prop>

            <prop key="hibernate.c3p0.idleConnectionTestPeriod">100</prop>

            <prop key="hibernate.c3p0.initialPoolSize">20</prop>
            <prop key="hibernate.c3p0.maxPoolSize">100</prop>
            <prop key="hibernate.c3p0.maxIdleTime">300</prop>
            <prop key="hibernate.c3p0.maxStatements">50</prop>
            <prop key="hibernate.c3p0.minPoolSize">10</prop>

            <prop key="hibernate.c3p0.preferredTestQuery">SELECT 1</prop>


            <prop key="hibernate.c3p0.testConnectionOnCheckout">true</prop>
            <prop key="show_sql">true</prop>
            
            <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>

            <prop key="hibernate.search.default.indexBase">d:\luceneFinal\</prop>
         </props>
      </property>

   </bean>


Top
 Profile  
 
 Post subject: Re: Beginner hibernate / spring / hiberante-search question
PostPosted: Tue Feb 15, 2011 8:19 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
I'm not sure I understood your question. The whole point of using the programmatic API is as an alternative to XML configuration - you're showing an XML configuration so I don't think you are interested in the programmatic API? If you are, you should start the SessionFactory and SearchFactory programmaticaly, not via an XML configuration. Of course you can still have your programmatic started read some configuration from XML, but that wouldn't be a standard Spring bean but something you code yourself.

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


Top
 Profile  
 
 Post subject: Re: Beginner hibernate / spring / hiberante-search question
PostPosted: Tue Feb 15, 2011 8:28 am 
Newbie

Joined: Tue Nov 09, 2010 12:45 pm
Posts: 7
The problem I am trying to solve is that I would like for hibernate-search to use the programmatic API so that I can define a FieldBridge that has server side dependencies. At the moment I use annotations on my client side domain objects to configure hibernate-search and I use XML for the general hibernate configuration.

According to the API docs for SpingDAO(http://www.docjar.org/docs/api/org/springframework/orm/hibernate3/support/HibernateDaoSupport.html) I should be able to use

HibernateTemplate ht = new HibernateTemplate(getSessionFactory());

and then somehow configure it.

I might be going in completely the wrong direction with this though, If you have any other ideas that would be worth following I would love to know!! :)

Cheers,
Rob


Top
 Profile  
 
 Post subject: Re: Beginner hibernate / spring / hiberante-search question
PostPosted: Tue Feb 15, 2011 9:08 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
there's an example in the unit tests.
Please checkout the sourcecode, and look into
1) org.hibernate.search.test.configuration.ProgrammaticSearchMappingFactory
2) org.hibernate.search.test.configuration.ProgrammaticMappingTest

(especially the configure method in ProgrammaticMappingTest)

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


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.