Tag: Maven
-
Spring Data JPA
Spring Data JPA provides a more cleaner approach of using JPA for DAO layer. It removes boilerplate code and developers can concentrate on actual logic. Our DataModel First create a maven project and add below dependencies: [sourcecode language=”xml”] <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mumz.test.springdata.jpa</groupId> <artifactId>SpringDataJPA</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <spring.version>3.2.4.RELEASE</spring.version> <spring.data.version>1.3.4.RELEASE</spring.data.version> <hibernate.version>4.2.5.FINAL</hibernate.version> <jpa.version>1.0.1.FINAL</jpa.version> <querydsl.version>3.2.3</querydsl.version> <junit.version>4.8.2</junit.version> </properties>…
-
Search Lucene Index created in database using JdbcDirectory
In our last excercise we created Lucene index in database using JdbcDirectory which comes with Compass in this post we will search against index created. With this much of text let’s get our hand dirty and write some code. Please note following files will be used from create lucene index post pom.xml MyJDBCDirectory.java JDBCBatchInsert.java JDBCIndexer.java…
-
Full Text Search with Hibernate Search 4.1, Lucene and JPA
Earlier we worked directly with Lucene API to create and search index Index and Search a Directory using Apache Lucene Create Lucene Index in database using JdbcDirectory”> Instead we can use HibernateSearch which internally uses Lucene functionality to index and search content. With that let’s get some code behind us. We will extend our code from JPA…
-
JPA OneToMany Unidirectional without Join Table
In earlier post we had OneToMany uni-directional mapping with the help of JoinTable. In this post we will see how can we make it unidirectional without using JoinTable. Let’s create our eclipse project and then add update our pom.xml. pom.xml [sourcecode language=”xml”] <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > <modelVersion>4.0.0</modelVersion> <groupId>com.mumz.test.hibernatesearch</groupId> <artifactId>MumzHibernateSearch</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>MumzHibernateSearch</name> <url>http://maven.apache.org</url>…
-
JPA OneToMany Unidirectional with Join Table
In earlier post we had OneToMany bi-directional mapping. In this post we will see how can we make it unidirectional with the usage of a JoinTable. Let’s create our eclipse project and then add update our pom.xml. pom.xml [sourcecode language=”xml”] <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > <modelVersion>4.0.0</modelVersion> <groupId>com.mumz.test.hibernatesearch</groupId> <artifactId>MumzHibernateSearch</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>MumzHibernateSearch</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>…
-
Create Lucene Index in database using JdbcDirectory
In our last post we built a simple index over file system. While our example works fine but cannot be extended over clustered environment and also cannot be used for a large document because of memory foot print. Lucene doesn’t provide a direct in built JDBC interface but Compass does, though the JDBC interface of…
-
Integrating Apache Lucene and Maven in Eclipse
In two steps we will integrate Apache Lucene and Maven in Eclipse. First Create Java Project using Maven in Eclipse Second add lucene dependency in your pom.xml, so you pom.xml should look like this: pom.xml [sourcecode language=”xml”] <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mumz.test.lucene</groupId> <artifactId>ApacheLuceneTest</artifactId> <version>0.0.1-SNAPSHOT</version> <name>ApacheLuceneTest</name> <description>ApacheLuceneTest</description> <dependencies> <dependency> <artifactId>lucene-core</artifactId> <groupId>org.apache.lucene</groupId> <type>jar</type> <version>3.6.1</version> </dependency>…
-
Index and Search a Directory using Apache Lucene
Building a custom search is a common requirement in almost every application. Building such a system can be complex and tedious with numerous use cases around. Apache Lucene is a search framework built in Java. In this tutorial we will write a small application which will use Lucene to search a given directory. Lucene works…
-
Audit Framework with Spring AOP and JPA
Every now and then we come across a common requirement of building an Audit framework. In simple words it means whenever a record is added, edited or removed there should be an entry made in a separate table so that different actions of users can be monitored. Today in this tutorial we will build an…
-
JPA OneToMany Mapping Using Hibernate and MySQL
OneToMany as name suggest is the scenario where one entity can be linked to multiple entities. For e.g. one BookShelf can contain multiple books. In this tutorial we will use the same problem statement and model it using JPA with Hibernate as the JPA implementation provider. First we will write our simple BookShelf entity, BookShelf…