This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| org.apache.lucene.search.Query luceneQuery = queryBuilder | |
| .keyword() | |
| .onField("email") | |
| .matching("edard.stark@winterfell.com") | |
| .createQuery(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Autowired | |
| private EntityManager entityManager; | |
| ... | |
| //inside UserDAO method | |
| FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager); | |
| QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Repository | |
| public class UserDAOImpl implements UserDAO { | |
| @PersistenceContext | |
| private EntityManager entityManager; | |
| @Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Service("userDetailService") | |
| public class LibraryUserDetailService implements UserDetailsService, UserService { | |
| @Autowired | |
| private UserDAO userDAO; | |
| @Override | |
| public List<com.wkrzywiec.spring.library.entity.User> searchUsers(String searchText, int pageNo, | |
| int resultsPerPage) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.stereotype.Controller; | |
| import org.springframework.ui.ModelMap; | |
| import org.springframework.web.bind.annotation.GetMapping; | |
| import org.springframework.web.bind.annotation.RequestParam; | |
| import com.wkrzywiec.spring.library.service.LibraryUserDetailService; | |
| @Controller | |
| public class LibraryController { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.persistence.*; | |
| import org.hibernate.search.annotations.*; | |
| @Entity | |
| @Table(name="user_detail") | |
| public class UserDetail { | |
| @Id | |
| @GeneratedValue(strategy=GenerationType.IDENTITY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.persistence.*; | |
| import org.hibernate.search.annotations.*; | |
| @Entity | |
| @Table(name="user") | |
| @Indexed | |
| public class User { | |
| @Id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.persistence.*; | |
| import javax.transaction.*; | |
| import org.hibernate.search.jpa.*; | |
| import org.springframework.context.ApplicationListener; | |
| import org.springframework.context.event.ContextRefreshedEvent; | |
| import org.springframework.stereotype.*; | |
| @Component |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| compile 'org.hibernate:hibernate-search-orm:5.9.1.Final' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.hibernate.search.annotations.*; | |
| @Entity | |
| @Table(name="user") | |
| @Indexed | |
| public class User { | |
| @Column(name="username") | |
| @Field | |
| private String username; |