-->
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.  [ 9 posts ] 
Author Message
 Post subject: Hibernate search returns empty array
PostPosted: Mon Feb 23, 2009 4:29 pm 
Newbie

Joined: Mon Feb 23, 2009 4:04 pm
Posts: 6
3.4.0 GA:

ApplicationContext.xml
Code:
<bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="dataSource">
         <ref bean="dataSource" />
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            <prop key="hibernate.connection.release_mode">${hibernate.connection.release_mode}
            </prop>
            [color=red]<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
            <prop key="hibernate.search.default.indexBase">indices</prop>[/color]
         </props>
      </property>
.....


Entity:
Code:
@SuppressWarnings("serial")
@Entity
@Indexed
@Inheritance(strategy = InheritanceType.JOINED)
public class User{

private String firstName;

private Long id;

@NotEmpty(message = "First name is required")
   @Field
   public String getFirstName() {
      return firstName;
   }

   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }

   @Id
   @GeneratedValue
   @DocumentId
   public Long getId() {
      return id;
   }
   private void setId(Long id) {
      this.id = id;
   }

}



Method that performs the search
Code:
public List<User> search(String keyword) {
FullTextSession fullTextSession = Search
            .getFullTextSession(getHibernateTemplate().getSessionFactory()
                  .getCurrentSession());

      // create native Lucene query
      String[] fields = new String[] { "firstName" };
      MultiFieldQueryParser parser = new MultiFieldQueryParser(fields,
            new SimpleAnalyzer());
      Query query;
      query = parser.parse(keyword);
      // wrap Lucene query in a org.hibernate.Query
      org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(
            query, User.class);

      // execute search
      return hibQuery.list();
}



Integration Test case
Code:
public void testSearch() throws ModelValidationException{
      user.setFirstName("james");
                userDAO.add(user) ;
      
      userDAO.search("james");
      
      assertTrue("Search Found nothing",userDAO.search("james").size() > 0);
   }



Problem I have with hibernate search is that it does not return any result.

All the inserts creates indexes, however luke cannot open it. It creates 2 files, segments.gen and segments_1. When I try to open it, it only prompts Error "0".

When I perform a search using above code, empty array is returned.

Read this: http://hibernate.org/42.html
Code:
[code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 4:23 am 
Hibernate Team
Hibernate Team

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

I am pretty sure that you are having problems with transactions. In your code you are calling the userDao twice in a row:
Code:
      user.setFirstName("james");
                userDAO.add(user) ;
     
      userDAO.search("james");

Does the first call actually create and commit in its own transaction. In order to successfully search the index has to be updated and that happens at transaction commit time. In your examples is would be interesting how you handle transactions.

Have for example a look at the Hibernate Search test cases. There you can see how there is always a part where some data gets indexed in one transaction and then searched in another (eg LuceneQueryTest).

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 12:01 pm 
Newbie

Joined: Mon Feb 23, 2009 4:04 pm
Posts: 6
I am using annotation based tx and my prev service call does commit the transaction. Is this correct way to do it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 12:30 pm 
Hibernate Team
Hibernate Team

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

which framework are you using for annotation based transaction management? Spring? Can you please post the code for your DAO?
Are you sure the transactions work properly? Try turning on debug trace for the tansactions to make sure that it works as expected.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 1:52 pm 
Newbie

Joined: Mon Feb 23, 2009 4:04 pm
Posts: 6
Here is more context around it. The transactions are getting commited, but no dice.

Test case
------------------------------------------

Code:
public void testSearch() throws ModelValidationException{
      user.setFirstName("james");
      organization.addUser(user);
      organizationService.add(organization);
      
      assertTrue("Search Found nothing",userService.search("james").size() > 0);
   }

-----------------------------------------------------------------------------------------
Logs for organizationService.add(organization);
-----------------------------------------------------------------------------------------
2009-02-24 11:38:45,452 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@366412da]
2009-02-24 11:38:45,452 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@366412da]
2009-02-24 11:38:45,452 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@366412da]
2009-02-24 11:38:45,454 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [com.greatMorning.service.OrganizationService.add]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2009-02-24 11:38:45,454 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [com.greatMorning.service.OrganizationService.add]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2009-02-24 11:38:45,454 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [com.greatMorning.service.OrganizationService.add]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2009-02-24 11:38:45,546 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:45,546 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:45,546 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:45,554 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@1817fe89]
2009-02-24 11:38:45,554 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@1817fe89]
2009-02-24 11:38:45,554 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@1817fe89]
2009-02-24 11:38:45,637 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@7f23663b]
2009-02-24 11:38:45,637 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@7f23663b]
2009-02-24 11:38:45,637 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@7f23663b]
2009-02-24 11:38:58,250 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:58,250 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:58,250 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:58,251 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@e7587b2]
2009-02-24 11:38:58,251 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@e7587b2]
2009-02-24 11:38:58,251 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@e7587b2]
2009-02-24 11:38:58,252 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Suspending current transaction, creating new transaction with name [com.greatMorning.service.UserService.isUniqueUser]
2009-02-24 11:38:58,252 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Suspending current transaction, creating new transaction with name [com.greatMorning.service.UserService.isUniqueUser]
2009-02-24 11:38:58,252 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Suspending current transaction, creating new transaction with name [com.greatMorning.service.UserService.isUniqueUser]
2009-02-24 11:38:58,258 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@3f68336] for Hibernate transaction
2009-02-24 11:38:58,258 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@3f68336] for Hibernate transaction
2009-02-24 11:38:58,258 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@3f68336] for Hibernate transaction
2009-02-24 11:38:58,259 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@3f68336]
2009-02-24 11:38:58,259 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@3f68336]
2009-02-24 11:38:58,259 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@3f68336]
2009-02-24 11:38:58,320 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@ab612f8]
2009-02-24 11:38:58,320 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@ab612f8]
2009-02-24 11:38:58,320 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@ab612f8]
2009-02-24 11:38:58,345 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@3f68336] for Hibernate transaction
2009-02-24 11:38:58,345 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@3f68336] for Hibernate transaction
2009-02-24 11:38:58,345 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@3f68336] for Hibernate transaction
2009-02-24 11:38:58,346 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@37975d46]
2009-02-24 11:38:58,346 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@37975d46]
2009-02-24 11:38:58,346 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@37975d46]
2009-02-24 11:38:58,346 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
2009-02-24 11:38:58,346 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
2009-02-24 11:38:58,346 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
Hibernate: select user0_.id as id1_, user0_.city as city1_, user0_.createDate as createDate1_, user0_.firstName as firstName1_, user0_.lastName as lastName1_, user0_.password as password1_, user0_.role as role1_, user0_.state_id as state11_1_, user0_.updateDate as updateDate1_, user0_.userName as userName1_, user0_.zipCode as zipCode1_, user0_1_.customerNumber as customer1_2_, user0_2_.organization_id as organiza4_7_, user0_2_.primary_user as primary1_7_, user0_2_.uuid as uuid7_, case when user0_1_.userId is not null then 1 when user0_2_.userId is not null then 2 when user0_.id is not null then 0 end as clazz_ from User user0_ left outer join ClientUser user0_1_ on user0_.id=user0_1_.userId left outer join OrganizationUser user0_2_ on user0_.id=user0_2_.userId where user0_.userName=?
2009-02-24 11:38:58,411 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:38:58,411 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:38:58,411 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:38:58,414 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:38:58,414 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:38:58,414 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:38:58,415 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:38:58,415 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:38:58,415 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:38:58,415 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@3f68336]
2009-02-24 11:38:58,415 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@3f68336]
2009-02-24 11:38:58,415 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@3f68336]
2009-02-24 11:38:58,417 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:38:58,417 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:38:58,417 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:38:58,421 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:38:58,421 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:38:58,421 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:38:58,422 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@3f68336] after transaction
2009-02-24 11:38:58,422 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@3f68336] after transaction
2009-02-24 11:38:58,422 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@3f68336] after transaction
2009-02-24 11:38:58,429 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Resuming suspended transaction
2009-02-24 11:38:58,429 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Resuming suspended transaction
2009-02-24 11:38:58,429 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Resuming suspended transaction
2009-02-24 11:38:59,045 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:59,045 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:59,045 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:38:59,046 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@18f55759]
2009-02-24 11:38:59,046 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@18f55759]
2009-02-24 11:38:59,046 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@18f55759]
2009-02-24 11:38:59,047 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
2009-02-24 11:38:59,047 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
2009-02-24 11:38:59,047 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
Hibernate: insert into Organization (active, createDate, name, updateDate, uuid) values (?, ?, ?, ?, ?)
Hibernate: insert into User (city, createDate, firstName, lastName, password, role, state_id, updateDate, userName, zipCode) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into OrganizationUser (organization_id, primary_user, uuid, userId) values (?, ?, ?, ?)
Hibernate: insert into EmailAddress (host, localPart, primary_email) values (?, ?, ?)
Hibernate: insert into PhoneNumber (areaCode, phoneNumber, primary_phone, type) values (?, ?, ?, ?)
2009-02-24 11:39:00,757 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:39:00,757 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:39:00,757 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Found thread-bound Session [org.hibernate.impl.SessionImpl@1817fe89] for Hibernate transaction
2009-02-24 11:39:00,758 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@40f92a41]
2009-02-24 11:39:00,758 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@40f92a41]
2009-02-24 11:39:00,758 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@40f92a41]
2009-02-24 11:39:00,759 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
2009-02-24 11:39:00,759 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
2009-02-24 11:39:00,759 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Participating in existing transaction
Hibernate: insert into AuditLog (auditType, createDate, entityClass, entityId, message, who_id) values (?, ?, ?, ?, ?, ?)
2009-02-24 11:39:03,915 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:39:03,915 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:39:03,915 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@1817fe89]
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@1817fe89]
2009-02-24 11:39:03,916 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@1817fe89]
Hibernate: insert into organization_users (organization_id, user_id) values (?, ?)
Hibernate: insert into UserEmailAddresses (user_id, email_address_id) values (?, ?)
Hibernate: insert into UserPhoneNumbers (user_id, phone_number_id) values (?, ?)
2009-02-24 11:39:03,941 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:39:03,941 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:39:03,941 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:39:03,942 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:39:03,942 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:39:03,942 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:39:03,942 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@1817fe89] after transaction
2009-02-24 11:39:03,942 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@1817fe89] after transaction
2009-02-24 11:39:03,942 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@1817fe89] after transaction

-----------------------------------------------------------
Logs for userDAO.search
-----------------------------------------------------------
2009-02-24 11:42:25,721 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@5d86aad9]
2009-02-24 11:42:25,721 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@5d86aad9]
2009-02-24 11:42:25,721 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Using transaction object [org.springframework.orm.hibernate3.HibernateTransactionManager$HibernateTransactionObject@5d86aad9]
2009-02-24 11:42:25,723 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [com.greatMorning.dao.UserDAO.search]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2009-02-24 11:42:25,723 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [com.greatMorning.dao.UserDAO.search]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2009-02-24 11:42:25,723 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Creating new transaction with name [com.greatMorning.dao.UserDAO.search]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2009-02-24 11:42:25,724 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@343abc87] for Hibernate transaction
2009-02-24 11:42:25,724 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@343abc87] for Hibernate transaction
2009-02-24 11:42:25,724 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Opened new Session [org.hibernate.impl.SessionImpl@343abc87] for Hibernate transaction
2009-02-24 11:42:25,725 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@343abc87]
2009-02-24 11:42:25,725 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@343abc87]
2009-02-24 11:42:25,725 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Not preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@343abc87]
2009-02-24 11:42:25,727 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@451dfada]
2009-02-24 11:42:25,727 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@451dfada]
2009-02-24 11:42:25,727 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Exposing Hibernate transaction as JDBC transaction [org.apache.commons.dbcp.PoolableConnection@451dfada]
2009-02-24 11:42:25,731 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:42:25,731 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:42:25,731 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCommit synchronization
2009-02-24 11:42:25,732 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:42:25,732 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:42:25,732 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering beforeCompletion synchronization
2009-02-24 11:42:25,733 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:42:25,733 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:42:25,733 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Initiating transaction commit
2009-02-24 11:42:25,734 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@343abc87]
2009-02-24 11:42:25,734 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@343abc87]
2009-02-24 11:42:25,734 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Committing Hibernate transaction on Session [org.hibernate.impl.SessionImpl@343abc87]
2009-02-24 11:42:25,735 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:42:25,735 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:42:25,735 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCommit synchronization
2009-02-24 11:42:25,736 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:42:25,736 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:42:25,736 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Triggering afterCompletion synchronization
2009-02-24 11:42:25,737 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@343abc87] after transaction
2009-02-24 11:42:25,737 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@343abc87] after transaction
2009-02-24 11:42:25,737 [main] DEBUG org.springframework.orm.hibernate3.HibernateTransactionManager - Closing Hibernate Session [org.hibernate.impl.SessionImpl@343abc87] after transaction

Relevant applicationContext.xml fragment
----------------------------------------------------------------------
Code:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
      lazy-init="true" autowire-candidate="false">
      <property name="driverClassName">
         <value>com.mysql.jdbc.Driver</value>
      </property>
      <property name="maxActive" value="100" />
      <property name="url" value="${hibernate.connection.url}" />
      <property name="username" value="${hibernate.connection.username}" />
      <property name="password" value="${hibernate.connection.password}" />
   </bean>

   <bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="dataSource">
         <ref bean="dataSource" />
      </property>
      <property name="hibernateProperties">
         <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            <prop key="hibernate.connection.release_mode">${hibernate.connection.release_mode}
            </prop>
            <prop key="hibernate.search.default.directory_provider">${hibernate.search.default.directory_provider}</prop>
            <prop key="hibernate.search.default.indexBase">${hibernate.search.default.indexBase}</prop>
         </props>
      </property>

      <property name="annotatedClasses">
         <list>
            ........
         </list>
      </property>
      
   </bean>

   <bean id="transactionManager"
      class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory">
         <ref bean="sessionFactory" />
      </property>
   </bean>

   <!-- This tells Spring to activate annotation-driven transactions -->
   <tx:annotation-driven transaction-manager="transactionManager"/>



OrganizationService.java
--------------------------------------------------------------

Code:
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT, readOnly = true)
public class OrganizationServiceImpl implements OrganizationService {


   @Transactional(readOnly = false)
   public Organization add(Organization organization) throws ModelValidationException {
      ...........
   }


UserService.java
----------------------------------------------------------
Code:
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT, readOnly = true, rollbackFor = Throwable.class)
public class UserServiceImpl implements UserService {


   private UserDAO userDAO;

   public List<User> search(String keyword) {
      return userDAO.search(keyword);
   }


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 12:57 pm 
Hibernate Team
Hibernate Team

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

I am pretty sure that the problem is transaction related. Have you tried a JTATransactionManager? Have a look at this post - http://forum.hibernate.org/viewtopic.php?t=994725

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 3:16 pm 
Newbie

Joined: Mon Feb 23, 2009 4:04 pm
Posts: 6
I will try with JPA using Open JPA. However, what should be the deciding factor on using transaction managers?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 02, 2009 6:36 am 
Hibernate Team
Hibernate Team

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

I think the problem is not so much which transaction manager, but rather ensuring that the chosen transaction manager is configured properly. It would for example be a good idea to check the actual implementations of the different Spring provided alternatives to find out what exactly is going on.

--Hardy


Top
 Profile  
 
 Post subject: Problem resolved
PostPosted: Mon Mar 02, 2009 1:12 pm 
Newbie

Joined: Mon Feb 23, 2009 4:04 pm
Posts: 6
My problem here was that the User entity that I was trying to index was a super class annotated as below:

Code:
@Inheritance(strategy = InheritanceType.JOINED)
public class User{


This was causing the problem. The resolution to this was to remove the @Index and @DocumentId annotation from User class. Annotated the subclasses with @Indexed.
Note It did not require me to add @DocumentId annotation anywhere, probably becuse i have @ID annotation.

Thanks for all the help.

Note It works with HibernateTransactionManager and I did not have to go the route of JPATransactionManager.


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