Hibernate SVN: r19354 - search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-03 12:14:35 -0400 (Mon, 03 May 2010)
New Revision: 19354
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
Log:
HSEARCH-333 removed logging
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java 2010-05-03 15:46:50 UTC (rev 19353)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/DocumentBuilderContainedEntity.java 2010-05-03 16:14:35 UTC (rev 19354)
@@ -425,13 +425,9 @@
}
protected void checkDocumentId(XProperty member, PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, InitContext context) {
- Annotation documentIdAnn = member.getAnnotation( DocumentId.class );
- if ( documentIdAnn != null ) {
- //FIXME commented until HSEARCH-333 is resolved
-// log.warn(
-// "@DocumentId specified on an entity which is not indexed by itself. Annotation gets ignored. Use @Field instead."
-// );
- }
+ // TODO - HSEARCH-333
+ // for a contained entity there is nothing to do here. This is really bad design since this protected method is called by the constructor and
+ // overridden by DocumentBuilderIndexedEntity
}
/**
14 years, 6 months
Hibernate SVN: r19353 - core/trunk/parent.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-05-03 11:46:50 -0400 (Mon, 03 May 2010)
New Revision: 19353
Modified:
core/trunk/parent/pom.xml
Log:
HHH-5186 update db profiles id and jdbc properties' name to use dballocator
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2010-05-03 15:36:41 UTC (rev 19352)
+++ core/trunk/parent/pom.xml 2010-05-03 15:46:50 UTC (rev 19353)
@@ -614,7 +614,7 @@
<!-- The MySQL 5 test envionment -->
<profile>
- <id>mysql-5.0</id>
+ <id>mysql50</id>
<dependencies>
<dependency>
<groupId>mysql</groupId>
@@ -635,7 +635,7 @@
<!-- The MySQL 5.1 test envionment -->
<profile>
- <id>mysql-5.1</id>
+ <id>mysql51</id>
<dependencies>
<dependency>
<groupId>mysql</groupId>
@@ -678,7 +678,7 @@
<!-- The PostgreSQL 8.2.4 test envionment -->
<profile>
- <id>postgresql-8.2</id>
+ <id>postgresql82</id>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
@@ -699,7 +699,7 @@
<!-- The PostgreSQL 8.3.7 test envionment -->
<profile>
- <id>postgresql-8.3</id>
+ <id>postgresql83</id>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
@@ -752,7 +752,7 @@
<!-- The DB2 9.1 test envionment (using 9x drivers)-->
<profile>
- <id>db2-9.1</id>
+ <id>db2-91</id>
<dependencies>
<dependency>
<groupId>com.ibm</groupId>
@@ -778,7 +778,7 @@
<!-- The DB2 9.7 test envionment (using 9x drivers)-->
<profile>
- <id>db2-9.7</id>
+ <id>db2-97</id>
<dependencies>
<dependency>
<groupId>com.ibm</groupId>
@@ -804,7 +804,7 @@
<!-- The Oracle9i test envionment -->
<profile>
- <id>oracle-9</id>
+ <id>oracle9i</id>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
@@ -826,7 +826,7 @@
<!-- The Oracle10g test envionment -->
<profile>
- <id>oracle1-10</id>
+ <id>oracle110g</id>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
@@ -848,7 +848,7 @@
<!-- The Oracle11g test envionment -->
<profile>
- <id>oracle-11</id>
+ <id>oracle11g</id>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
@@ -869,7 +869,7 @@
<!-- The Oracle11gRAC test envionment -->
<profile>
- <id>oracle-11rac</id>
+ <id>oracle-11RAC</id>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
@@ -892,7 +892,7 @@
<!-- The Sybase 15 test envionment -->
<profile>
- <id>sybase-15</id>
+ <id>sybase15</id>
<dependencies>
<dependency>
<groupId>com.sybase</groupId>
@@ -913,7 +913,7 @@
<!-- The SQLServer2005 (MS JDBC) test envionment -->
<profile>
- <id>mssql-2005</id>
+ <id>mssql2005</id>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
@@ -934,7 +934,7 @@
<!-- The SQLServer2005 (MS JDBC) test envionment -->
<profile>
- <id>mssql-2008</id>
+ <id>mssql2008</id>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
14 years, 6 months
Hibernate SVN: r19352 - in search/trunk: hibernate-search/src/main/docbook/en-US and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-03 11:36:41 -0400 (Mon, 03 May 2010)
New Revision: 19352
Modified:
search/trunk/hibernate-search-archetype/pom.xml
search/trunk/hibernate-search/pom.xml
search/trunk/hibernate-search/src/main/docbook/en-US/master.xml
search/trunk/hibernate-search/src/main/docbook/en-US/modules/getting-started.xml
Log:
HSEARCH-486 - Updated the getting started section. Removed the mention of the archetype which is not really a problem given that we cannot deploy the archetype catalog for now anyways
Modified: search/trunk/hibernate-search/pom.xml
===================================================================
--- search/trunk/hibernate-search/pom.xml 2010-05-03 14:33:56 UTC (rev 19351)
+++ search/trunk/hibernate-search/pom.xml 2010-05-03 15:36:41 UTC (rev 19352)
@@ -184,6 +184,9 @@
<docbookVersion>1.72.0</docbookVersion>
<localeSeparator>-</localeSeparator>
</options>
+ <profiling>
+ <enabled>true</enabled>
+ </profiling>
</configuration>
</plugin>
<plugin>
Modified: search/trunk/hibernate-search/src/main/docbook/en-US/master.xml
===================================================================
--- search/trunk/hibernate-search/src/main/docbook/en-US/master.xml 2010-05-03 14:33:56 UTC (rev 19351)
+++ search/trunk/hibernate-search/src/main/docbook/en-US/master.xml 2010-05-03 15:36:41 UTC (rev 19352)
@@ -29,7 +29,7 @@
<!ENTITY copyrightYear "2004">
<!ENTITY copyrightHolder "Red Hat Middleware, LLC.">
]>
-<book lang="en">
+<book>
<bookinfo>
<title>Hibernate Search</title>
Modified: search/trunk/hibernate-search/src/main/docbook/en-US/modules/getting-started.xml
===================================================================
--- search/trunk/hibernate-search/src/main/docbook/en-US/modules/getting-started.xml 2010-05-03 14:33:56 UTC (rev 19351)
+++ search/trunk/hibernate-search/src/main/docbook/en-US/modules/getting-started.xml 2010-05-03 15:36:41 UTC (rev 19352)
@@ -25,7 +25,7 @@
-->
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY version "WORKING">
+<!ENTITY version "3.2.0.Final">
]>
<chapter id="getting-started">
<title>Getting started</title>
@@ -98,21 +98,64 @@
<para>Instead of managing all dependencies manually, maven users have the
possibility to use the <ulink
- url="http://repository.jboss.com/maven2">JBoss maven repository</ulink>.
- Just add the JBoss repository url to the <emphasis>repositories</emphasis>
- section of your <filename>pom.xml</filename> or
- <filename>settings.xml</filename>:</para>
+ url="https://repository.jboss.org/nexus/content/groups/public/">JBoss
+ maven repository</ulink>. Add the following to your Maven
+ <filename>settings.xml file</filename> (see also <ulink
+ url="http://community.jboss.org/wiki/MavenGettingStarted-Users">Maven
+ Getting Started</ulink>):</para>
<example>
<title>Adding the JBoss maven repository to
<filename>settings.xml</filename></title>
- <programlisting><repository>
- <id>repository.jboss.org</id>
- <name>JBoss Maven Repository</name>
- <url>http://repository.jboss.org/maven2</url>
- <layout>default</layout>
-</repository> </programlisting>
+ <programlisting><settings>
+ ...
+ <profiles>
+ ...
+ <profile>
+ <id>jboss-public-repository</id>
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+
+ </profiles>
+
+ <activeProfiles>
+ <activeProfile>jboss-public-repository</activeProfile>
+ </activeProfiles>
+ ...
+</settings>
+ </programlisting>
</example>
<para>Then add the following dependencies to your pom.xml:</para>
@@ -132,28 +175,19 @@
</dependency></programlisting>
</example>
- <para>Not all dependencies are required. Only the
- <emphasis>hibernate-search</emphasis> dependency is mandatory. This
- dependency, together with its required transitive dependencies, contain
- all required classes needed to use Hibernate Search.</para>
+ <para>Only the <emphasis>hibernate-search</emphasis> dependency is
+ mandatory, because it contains together with its required transitive
+ dependencies all required classes needed to use Hibernate
+ Search.<emphasis> hibernate-entitymanager</emphasis> is only required if
+ you want to use Hibernate Search in conjunction with JPA.</para>
- <para><emphasis>hibernate-annotations</emphasis> is needed if you want to
- use annotations to configure your domain model but don't want to use JPA's
- runtime APIs. If you choose not to use Hibernate Annotations and describe
- your ORM mapping using <filename>cfg.xml</filename> files, you still have
- to use the Hibernate Search specific annotations, which are bundled with
- the hibernate-search jar file, to configure your Lucene index. There is no
- XML configuration available for Hibernate Search but we provide a powerful
- programmatic mapping API that elegantly replace this kind of deployment
- descriptor (see <xref linkend="hsearch-mapping-programmaticapi" /> for
- more information).</para>
-
- <para><emphasis>hibernate-entitymanager</emphasis> is required if you want
- to use Hibernate Search in conjunction with JPA.</para>
-
- <para>And finally, you might want to add optional dependencies related to
- Lucene (if you use some of the contribs of Lucene). By default, we add
- lucene-snowball and lucene-analyzers as dependencies.</para>
+ <para><note>
+ <para>There is no XML configuration available for Hibernate Search but
+ we provide a powerful programmatic mapping API that elegantly replace
+ this kind of deployment form (see <xref
+ linkend="hsearch-mapping-programmaticapi" /> for more
+ information).</para>
+ </note></para>
</section>
<section>
@@ -374,12 +408,12 @@
<title>Indexing</title>
<para>Hibernate Search will transparently index every entity persisted,
- updated or removed through Hibernate Core. However, you have to trigger an
- initial indexing to populate the Lucene index with the data already
- present in your database. Once you have added the above properties and
- annotations it is time to trigger an initial batch index of your books.
- You can achieve this by using one of the following code snippets (see also
- <xref linkend="search-batchindex" />):</para>
+ updated or removed through Hibernate Core. However, you have to create an
+ initial Lucene index for the data already present in your database. Once
+ you have added the above properties and annotations it is time to trigger
+ an initial batch index of your books. You can achieve this by using one of
+ the following code snippets (see also <xref
+ linkend="search-batchindex" />):</para>
<example>
<title>Using Hibernate Session to index data</title>
@@ -562,27 +596,8 @@
<section>
<title>What's next</title>
- <para>The above paragraphs hopefully helped you getting an overview of
- Hibernate Search. Using the maven archetype plugin and the following
- command you can create an initial runnable maven project structure
- populated with the example code of this tutorial.</para>
-
- <example>
- <title>Using the Maven archetype to create tutorial sources</title>
-
- <programlisting>mvn archetype:create \
- -DarchetypeGroupId=org.hibernate \
- -DarchetypeArtifactId=hibernate-search-quickstart \
- -DarchetypeVersion=&version; \
- -DgroupId=my.company -DartifactId=quickstart</programlisting>
- </example>
-
- <para>Using the maven project you can execute the examples, inspect the
- file system based index and search and retrieve a list of managed objects.
- Just run <emphasis>mvn package</emphasis> to compile the sources and run
- the unit tests.</para>
-
- <para>The next step after this tutorial is to get more familiar with the
+ <para>The above paragraphs helped you getting an overview of Hibernate
+ Search. The next step after this tutorial is to get more familiar with the
overall architecture of Hibernate Search (<xref
linkend="search-architecture" />) and explore the basic features in more
detail. Two topics which were only briefly touched in this tutorial were
Modified: search/trunk/hibernate-search-archetype/pom.xml
===================================================================
--- search/trunk/hibernate-search-archetype/pom.xml 2010-05-03 14:33:56 UTC (rev 19351)
+++ search/trunk/hibernate-search-archetype/pom.xml 2010-05-03 15:36:41 UTC (rev 19352)
@@ -32,40 +32,6 @@
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-core</artifactId>
- <exclusions>
- <exclusion>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- </exclusion>
- <exclusion>
- <groupId>woodstox</groupId>
- <artifactId>wstx-asl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>net.java.dev.stax-utils</groupId>
- <artifactId>stax-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.solr</groupId>
- <artifactId>solr-lucene-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-snowball</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-analyzers</artifactId>
- </dependency>
- <dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.2</version>
14 years, 6 months
Hibernate SVN: r19351 - core/trunk/parent.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-05-03 10:33:56 -0400 (Mon, 03 May 2010)
New Revision: 19351
Modified:
core/trunk/parent/pom.xml
Log:
HHH-5186 update db profiles id and jdbc properties' name to use dballocator
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2010-05-03 13:47:33 UTC (rev 19350)
+++ core/trunk/parent/pom.xml 2010-05-03 14:33:56 UTC (rev 19351)
@@ -614,7 +614,7 @@
<!-- The MySQL 5 test envionment -->
<profile>
- <id>mysql5</id>
+ <id>mysql-5.0</id>
<dependencies>
<dependency>
<groupId>mysql</groupId>
@@ -635,7 +635,7 @@
<!-- The MySQL 5.1 test envionment -->
<profile>
- <id>mysql51</id>
+ <id>mysql-5.1</id>
<dependencies>
<dependency>
<groupId>mysql</groupId>
@@ -678,7 +678,7 @@
<!-- The PostgreSQL 8.2.4 test envionment -->
<profile>
- <id>postgresql824</id>
+ <id>postgresql-8.2</id>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
@@ -699,7 +699,7 @@
<!-- The PostgreSQL 8.3.7 test envionment -->
<profile>
- <id>postgresql837</id>
+ <id>postgresql-8.3</id>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
@@ -752,7 +752,7 @@
<!-- The DB2 9.1 test envionment (using 9x drivers)-->
<profile>
- <id>db2v91</id>
+ <id>db2-9.1</id>
<dependencies>
<dependency>
<groupId>com.ibm</groupId>
@@ -778,7 +778,7 @@
<!-- The DB2 9.7 test envionment (using 9x drivers)-->
<profile>
- <id>db2v97</id>
+ <id>db2-9.7</id>
<dependencies>
<dependency>
<groupId>com.ibm</groupId>
@@ -804,7 +804,7 @@
<!-- The Oracle9i test envionment -->
<profile>
- <id>oracle9i</id>
+ <id>oracle-9</id>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
@@ -826,7 +826,7 @@
<!-- The Oracle10g test envionment -->
<profile>
- <id>oracle10g</id>
+ <id>oracle1-10</id>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
@@ -848,7 +848,7 @@
<!-- The Oracle11g test envionment -->
<profile>
- <id>oracle11g</id>
+ <id>oracle-11</id>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
@@ -869,7 +869,7 @@
<!-- The Oracle11gRAC test envionment -->
<profile>
- <id>oracle11gRAC</id>
+ <id>oracle-11rac</id>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
@@ -892,7 +892,7 @@
<!-- The Sybase 15 test envionment -->
<profile>
- <id>sybase15</id>
+ <id>sybase-15</id>
<dependencies>
<dependency>
<groupId>com.sybase</groupId>
@@ -913,7 +913,7 @@
<!-- The SQLServer2005 (MS JDBC) test envionment -->
<profile>
- <id>mssql2005</id>
+ <id>mssql-2005</id>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
@@ -934,7 +934,7 @@
<!-- The SQLServer2005 (MS JDBC) test envionment -->
<profile>
- <id>mssql2008</id>
+ <id>mssql-2008</id>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
14 years, 6 months
Hibernate SVN: r19350 - in core/trunk/testsuite/src/test/java/org/hibernate/test: resulttransformer and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: sharathjreddy
Date: 2010-05-03 09:47:33 -0400 (Mon, 03 May 2010)
New Revision: 19350
Added:
core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/
core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/Contract.hbm.xml
core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/Contract.java
core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/PartnerA.java
core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/PartnerB.java
core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/ResultTransformerTest.java
Log:
HHH-3694 ResultTransformer not used when scroll() is used on a named SQLQuery
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/Contract.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/Contract.hbm.xml (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/Contract.hbm.xml 2010-05-03 13:47:33 UTC (rev 19350)
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="org.hibernate.test.resulttransformer.Contract">
+ <id name="id" type="long">
+ <column name="id" />
+ <generator class="native" />
+ </id>
+ <property name="name" />
+ <many-to-one name="a"/>
+ <many-to-one name="b"/>
+ <sql-query name="testQuery">
+ <return alias="d" class="org.hibernate.test.resulttransformer.Contract"/>
+ <return-join alias="a" property="d.a"/>
+ <return-join alias="b" property="d.b"/>
+ <![CDATA[
+ select
+ {d.*}, {a.*}, {b.*}
+ from
+ Contract d, PartnerA a, PartnerB b
+ where d.a = a.id and d.b = b.id
+ ]]>
+ </sql-query>
+ </class>
+ <class name="org.hibernate.test.resulttransformer.PartnerA">
+ <id name="id" type="long">
+ <column name="id" />
+ <generator class="native" />
+ </id>
+ <property name="name" />
+ </class>
+ <class name="org.hibernate.test.resulttransformer.PartnerB">
+ <id name="id" type="long">
+ <column name="id" />
+ <generator class="native" />
+ </id>
+ <property name="name" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/Contract.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/Contract.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/Contract.java 2010-05-03 13:47:33 UTC (rev 19350)
@@ -0,0 +1,91 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-
+ * party contributors as indicated by the @author tags or express
+ * copyright attribution statements applied by the authors.
+ * All third-party contributions are distributed under license by
+ * Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to
+ * use, modify, copy, or redistribute it subject to the terms and
+ * conditions of the GNU Lesser General Public License, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this distribution; if not, write to:
+ *
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.resulttransformer;
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+public class Contract {
+
+ private Long id;
+ private String name;
+ private PartnerA a;
+ private PartnerB b;
+ private Long custom1;
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public PartnerA getA()
+ {
+ return a;
+ }
+
+ public void setA(PartnerA a)
+ {
+ this.a = a;
+ }
+
+ public PartnerB getB()
+ {
+ return b;
+ }
+
+ public void setB(PartnerB b)
+ {
+ this.b = b;
+ }
+
+ public Long getCustom1()
+ {
+ return custom1;
+ }
+
+ public void setCustom1(Long custom1)
+ {
+ this.custom1 = custom1;
+ }
+}
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/PartnerA.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/PartnerA.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/PartnerA.java 2010-05-03 13:47:33 UTC (rev 19350)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-
+ * party contributors as indicated by the @author tags or express
+ * copyright attribution statements applied by the authors.
+ * All third-party contributions are distributed under license by
+ * Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to
+ * use, modify, copy, or redistribute it subject to the terms and
+ * conditions of the GNU Lesser General Public License, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this distribution; if not, write to:
+ *
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.resulttransformer;
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+public class PartnerA {
+
+ private Long id;
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
\ No newline at end of file
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/PartnerB.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/PartnerB.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/PartnerB.java 2010-05-03 13:47:33 UTC (rev 19350)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-
+ * party contributors as indicated by the @author tags or express
+ * copyright attribution statements applied by the authors.
+ * All third-party contributions are distributed under license by
+ * Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to
+ * use, modify, copy, or redistribute it subject to the terms and
+ * conditions of the GNU Lesser General Public License, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this distribution; if not, write to:
+ *
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.resulttransformer;
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+public class PartnerB {
+
+ private Long id;
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
Added: core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/ResultTransformerTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/ResultTransformerTest.java (rev 0)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/resulttransformer/ResultTransformerTest.java 2010-05-03 13:47:33 UTC (rev 19350)
@@ -0,0 +1,108 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-
+ * party contributors as indicated by the @author tags or express
+ * copyright attribution statements applied by the authors.
+ * All third-party contributions are distributed under license by
+ * Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to
+ * use, modify, copy, or redistribute it subject to the terms and
+ * conditions of the GNU Lesser General Public License, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this distribution; if not, write to:
+ *
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+
+package org.hibernate.test.resulttransformer;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.transform.ResultTransformer;
+
+/**
+ * @author Sharath Reddy
+ *
+ */
+public class ResultTransformerTest extends FunctionalTestCase {
+
+ public ResultTransformerTest(String string) {
+ super(string);
+ }
+
+ /**
+ * HHH-3694 ResultTransformer not used when scroll() is used on a named SQLQuery
+ */
+ public void testResultTransformerIsAppliedToScrollableResults() throws Exception
+ {
+ Session s = openSession();
+ Transaction tx = s.beginTransaction();
+
+ PartnerA a = new PartnerA();
+ a.setName("Partner A");
+ PartnerB b = new PartnerB();
+ b.setName("Partner B");
+ Contract obj1 = new Contract();
+ obj1.setName("Contract");
+ obj1.setA(a);
+ obj1.setB(b);
+ s.save(a);
+ s.save(b);
+ s.save(obj1);
+
+ tx.commit();
+ s.close();
+
+ s = openSession();
+
+ Query q = s.getNamedQuery(Contract.class.getName() + ".testQuery");
+ q.setFetchSize(100);
+ q.setResultTransformer(new ResultTransformer() {
+
+ private static final long serialVersionUID = -5815434828170704822L;
+
+ public Object transformTuple(Object[] arg0, String[] arg1)
+ {
+ // return only the PartnerA object from the query
+ return arg0[1];
+ }
+
+ @SuppressWarnings("unchecked")
+ public List transformList(List arg0)
+ {
+ return arg0;
+ }
+ });
+ ScrollableResults sr = q.scroll();
+ sr.first();
+ Object[] row = sr.get();
+ assertEquals(1, row.length);
+ Object obj = row[0];
+ assertTrue(obj instanceof PartnerA);
+ PartnerA obj2 = (PartnerA) obj;
+ assertEquals("Partner A", obj2.getName());
+ s.close();
+ }
+
+ public String[] getMappings() {
+ return new String[] { "resulttransformer/Contract.hbm.xml" };
+ }
+}
+
+
14 years, 6 months
Hibernate SVN: r19349 - core/trunk/core/src/main/java/org/hibernate/loader/custom.
by hibernate-commits@lists.jboss.org
Author: sharathjreddy
Date: 2010-05-03 09:45:20 -0400 (Mon, 03 May 2010)
New Revision: 19349
Modified:
core/trunk/core/src/main/java/org/hibernate/loader/custom/CustomLoader.java
Log:
HHH-3694 ResultTransformer not used when scroll() is used on a named SQLQuery
Modified: core/trunk/core/src/main/java/org/hibernate/loader/custom/CustomLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/custom/CustomLoader.java 2010-05-03 12:12:06 UTC (rev 19348)
+++ core/trunk/core/src/main/java/org/hibernate/loader/custom/CustomLoader.java 2010-05-03 13:45:20 UTC (rev 19349)
@@ -328,7 +328,7 @@
}
static private HolderInstantiator getHolderInstantiator(ResultTransformer resultTransformer, String[] queryReturnAliases) {
- if ( resultTransformer != null ) {
+ if ( resultTransformer == null ) {
return HolderInstantiator.NOOP_INSTANTIATOR;
}
else {
14 years, 6 months
Hibernate SVN: r19347 - in search/trunk/hibernate-search-archetype: src/main/archetype and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-03 08:10:11 -0400 (Mon, 03 May 2010)
New Revision: 19347
Added:
search/trunk/hibernate-search-archetype/archetype.properties
search/trunk/hibernate-search-archetype/src/main/java/com/
search/trunk/hibernate-search-archetype/src/main/java/com/example/
search/trunk/hibernate-search-archetype/src/main/java/com/example/Author.java
search/trunk/hibernate-search-archetype/src/main/java/com/example/Book.java
search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java
Removed:
search/trunk/hibernate-search-archetype/src/main/archetype/archetype.properties
search/trunk/hibernate-search-archetype/src/main/java/com/
search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java
Modified:
search/trunk/hibernate-search-archetype/pom.xml
Log:
HSEARCh-503 Updated archetype
Copied: search/trunk/hibernate-search-archetype/archetype.properties (from rev 19345, search/trunk/hibernate-search-archetype/src/main/archetype/archetype.properties)
===================================================================
--- search/trunk/hibernate-search-archetype/archetype.properties (rev 0)
+++ search/trunk/hibernate-search-archetype/archetype.properties 2010-05-03 12:10:11 UTC (rev 19347)
@@ -0,0 +1,7 @@
+archetype.artifactId=hibernate-search-quickstart
+archetype.version=2.0
+
+archetype.filteredExtensions=java
+archetype.languages=java
+
+
Property changes on: search/trunk/hibernate-search-archetype/archetype.properties
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: search/trunk/hibernate-search-archetype/pom.xml
===================================================================
--- search/trunk/hibernate-search-archetype/pom.xml 2010-05-03 11:59:44 UTC (rev 19346)
+++ search/trunk/hibernate-search-archetype/pom.xml 2010-05-03 12:10:11 UTC (rev 19347)
@@ -1,7 +1,9 @@
<?xml version="1.0"?>
-<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/maven-v4_0_0.xsd">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
+
<!--
The link to the hibernate-search parent POM only exists out of convenience.
If you want to continue using this quick-start project you should remove this
@@ -11,19 +13,19 @@
<artifactId>hibernate-search-parent</artifactId>
<groupId>org.hibernate</groupId>
<version>3.2.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
</parent>
-
+
+ <groupId>com.example</groupId>
<artifactId>hibernate-search-archetype</artifactId>
<packaging>jar</packaging>
<name>Hibernate Search Archetype</name>
<url>http://www.myorganization.org</url>
-
+
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
- <version>${pom.version}</version>
+ <version>${parent.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -73,9 +75,9 @@
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
- </dependency>
+ </dependency>
</dependencies>
-
+
<build>
<plugins>
<plugin>
@@ -92,6 +94,10 @@
<skip>true</skip>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-archetype-plugin</artifactId>
+ </plugin>
</plugins>
</build>
</project>
Deleted: search/trunk/hibernate-search-archetype/src/main/archetype/archetype.properties
===================================================================
--- search/trunk/hibernate-search-archetype/src/main/archetype/archetype.properties 2010-05-03 11:59:44 UTC (rev 19346)
+++ search/trunk/hibernate-search-archetype/src/main/archetype/archetype.properties 2010-05-03 12:10:11 UTC (rev 19347)
@@ -1,3 +0,0 @@
-archetype.groupId=org.hibernate
-archetype.artifactId=hibernate-search-quickstart
-
Added: search/trunk/hibernate-search-archetype/src/main/java/com/example/Author.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/main/java/com/example/Author.java (rev 0)
+++ search/trunk/hibernate-search-archetype/src/main/java/com/example/Author.java 2010-05-03 12:10:11 UTC (rev 19347)
@@ -0,0 +1,35 @@
+// $Id: com.example.Author.java 17630 2009-10-06 13:38:43Z sannegrinovero $
+package com.example;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Store;
+
+@Entity
+public class Author {
+ @Id
+ @GeneratedValue
+ private Integer id;
+ private String name;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: search/trunk/hibernate-search-archetype/src/main/java/com/example/Book.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/main/java/com/example/Book.java (rev 0)
+++ search/trunk/hibernate-search-archetype/src/main/java/com/example/Book.java 2010-05-03 12:10:11 UTC (rev 19347)
@@ -0,0 +1,99 @@
+// $Id: com.example.Book.java 17630 2009-10-06 13:38:43Z sannegrinovero $
+package com.example;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+
+import org.apache.solr.analysis.LowerCaseFilterFactory;
+import org.apache.solr.analysis.SnowballPorterFilterFactory;
+import org.apache.solr.analysis.StandardTokenizerFactory;
+
+import org.hibernate.search.annotations.Analyzer;
+import org.hibernate.search.annotations.AnalyzerDef;
+import org.hibernate.search.annotations.DateBridge;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.Parameter;
+import org.hibernate.search.annotations.Resolution;
+import org.hibernate.search.annotations.Store;
+import org.hibernate.search.annotations.TokenFilterDef;
+import org.hibernate.search.annotations.TokenizerDef;
+
+@Entity
+@AnalyzerDef(name = "customanalyzer",
+ tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
+ filters = {
+ @TokenFilterDef(factory = LowerCaseFilterFactory.class),
+ @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
+ @Parameter(name = "language", value = "English")
+ })
+ })
+@Indexed
+public class Book {
+
+ private Integer id;
+ private String title;
+ private String subtitle;
+ private Set<Author> authors = new HashSet<Author>();
+ private Date publicationDate;
+
+ @IndexedEmbedded
+ @ManyToMany
+ public Set<Author> getAuthors() {
+ return authors;
+ }
+
+ public void setAuthors(Set<Author> authors) {
+ this.authors = authors;
+ }
+
+ public Book() {
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.YES)
+ @Analyzer(definition = "customanalyzer")
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Id
+ @DocumentId
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Field(index = Index.TOKENIZED, store = Store.NO)
+ @Analyzer(definition = "customanalyzer")
+ public String getSubtitle() {
+ return subtitle;
+ }
+
+ public void setSubtitle(String subtitle) {
+ this.subtitle = subtitle;
+ }
+
+ @Field(index = Index.UN_TOKENIZED, store = Store.YES)
+ @DateBridge(resolution = Resolution.DAY)
+ public Date getPublicationDate() {
+ return publicationDate;
+ }
+
+ public void setPublicationDate(Date publicationDate) {
+ this.publicationDate = publicationDate;
+ }
+}
\ No newline at end of file
Deleted: search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java 2010-05-03 11:59:44 UTC (rev 19346)
+++ search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java 2010-05-03 12:10:11 UTC (rev 19347)
@@ -1,169 +0,0 @@
-/* $Id: IndexAndSearchTest.java 18745 2010-02-09 13:00:22Z sannegrinovero $
- *
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package com.example;
-
-import com.example.Book;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.queryParser.MultiFieldQueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.util.Version;
-import org.hibernate.Session;
-import org.hibernate.ejb.Ejb3Configuration;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.jpa.FullTextEntityManager;
-import org.hibernate.search.jpa.FullTextQuery;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Query;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Example testcase for Hibernate Search
- */
-public class IndexAndSearchTest {
-
- private EntityManagerFactory emf;
-
- private EntityManager em;
-
- private static Logger log = LoggerFactory.getLogger(IndexAndSearchTest.class);
-
- @Before
- public void setUp() {
- initHibernate();
- }
-
- @After
- public void tearDown() {
- purge();
- }
-
- @Test
- public void testIndexAndSearch() throws Exception {
- List<Book> books = search("hibernate");
- assertEquals("Should get empty list since nothing is indexed yet", 0, books.size());
-
- index();
-
- // search by title
- books = search("hibernate");
- assertEquals("Should find one book", 1, books.size());
- assertEquals("Wrong title", "Java Persistence with Hibernate", books.get(0).getTitle());
-
- // search author
- books = search("\"Gavin King\"");
- assertEquals("Should find one book", 1, books.size());
- assertEquals("Wrong title", "Java Persistence with Hibernate", books.get(0).getTitle());
- }
-
- @Test
- public void testStemming() throws Exception {
-
- index();
-
- List<Book> books = search("refactor");
- assertEquals("Wrong title", "Refactoring: Improving the Design of Existing Code", books.get(0).getTitle());
-
- books = search("refactors");
- assertEquals("Wrong title", "Refactoring: Improving the Design of Existing Code", books.get(0).getTitle());
-
- books = search("refactored");
- assertEquals("Wrong title", "Refactoring: Improving the Design of Existing Code", books.get(0).getTitle());
-
- books = search("refactoring");
- assertEquals("Wrong title", "Refactoring: Improving the Design of Existing Code", books.get(0).getTitle());
- }
-
-
- private void initHibernate() {
- Ejb3Configuration config = new Ejb3Configuration();
- config.configure("hibernate-search-example", new HashMap());
- emf = config.buildEntityManagerFactory();
- em = emf.createEntityManager();
- }
-
- private void index() {
- FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession((Session) em.getDelegate());
- try {
- ftSession.createIndexer().startAndWait();
- }
- catch (InterruptedException e) {
- log.error( "Was interrupted during indexing", e );
- }
- }
-
- private void purge() {
- FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession((Session) em.getDelegate());
- ftSession.purgeAll(Book.class);
- ftSession.flushToIndexes();
- }
-
- private List<Book> search(String searchQuery) throws ParseException {
- Query query = searchQuery(searchQuery);
-
- List<Book> books = query.getResultList();
-
- for (Book b : books) {
- log.info("Title: " + b.getTitle());
- }
- return books;
- }
-
- private Query searchQuery(String searchQuery) throws ParseException {
-
- String[] bookFields = {"title", "subtitle", "authors.name", "publicationDate"};
-
- //lucene part
- Map<String, Float> boostPerField = new HashMap<String, Float>(4);
- boostPerField.put(bookFields[0], (float) 4);
- boostPerField.put(bookFields[1], (float) 3);
- boostPerField.put(bookFields[2], (float) 4);
- boostPerField.put(bookFields[3], (float) .5);
-
- FullTextEntityManager ftEm = org.hibernate.search.jpa.Search.getFullTextEntityManager((EntityManager) em);
- Analyzer customAnalyzer = ftEm.getSearchFactory().getAnalyzer("customanalyzer");
- QueryParser parser = new MultiFieldQueryParser(Version.LUCENE_29, bookFields,
- customAnalyzer, boostPerField);
-
- org.apache.lucene.search.Query luceneQuery;
- luceneQuery = parser.parse(searchQuery);
-
- final FullTextQuery query = ftEm.createFullTextQuery(luceneQuery, Book.class);
-
- return query;
- }
-
-}
Added: search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java
===================================================================
--- search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java (rev 0)
+++ search/trunk/hibernate-search-archetype/src/test/java/com/example/IndexAndSearchTest.java 2010-05-03 12:10:11 UTC (rev 19347)
@@ -0,0 +1,147 @@
+package com.example;// $Id: com.example.IndexAndSearchTest.java 18745 2010-02-09 13:00:22Z sannegrinovero $
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.queryParser.MultiFieldQueryParser;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.util.Version;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.Session;
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.jpa.FullTextEntityManager;
+import org.hibernate.search.jpa.FullTextQuery;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Example testcase for Hibernate Search
+ */
+public class IndexAndSearchTest {
+
+ private EntityManagerFactory emf;
+
+ private EntityManager em;
+
+ private static Logger log = LoggerFactory.getLogger( IndexAndSearchTest.class );
+
+ @Before
+ public void setUp() {
+ initHibernate();
+ }
+
+ @After
+ public void tearDown() {
+ purge();
+ }
+
+ @Test
+ public void testIndexAndSearch() throws Exception {
+ List<Book> books = search( "hibernate" );
+ assertEquals( "Should get empty list since nothing is indexed yet", 0, books.size() );
+
+ index();
+
+ // search by title
+ books = search( "hibernate" );
+ assertEquals( "Should find one book", 1, books.size() );
+ assertEquals( "Wrong title", "Java Persistence with Hibernate", books.get( 0 ).getTitle() );
+
+ // search author
+ books = search( "\"Gavin King\"" );
+ assertEquals( "Should find one book", 1, books.size() );
+ assertEquals( "Wrong title", "Java Persistence with Hibernate", books.get( 0 ).getTitle() );
+ }
+
+ @Test
+ public void testStemming() throws Exception {
+
+ index();
+
+ List<Book> books = search( "refactor" );
+ assertEquals( "Wrong title", "Refactoring: Improving the Design of Existing Code", books.get( 0 ).getTitle() );
+
+ books = search( "refactors" );
+ assertEquals( "Wrong title", "Refactoring: Improving the Design of Existing Code", books.get( 0 ).getTitle() );
+
+ books = search( "refactored" );
+ assertEquals( "Wrong title", "Refactoring: Improving the Design of Existing Code", books.get( 0 ).getTitle() );
+
+ books = search( "refactoring" );
+ assertEquals( "Wrong title", "Refactoring: Improving the Design of Existing Code", books.get( 0 ).getTitle() );
+ }
+
+
+ private void initHibernate() {
+ Ejb3Configuration config = new Ejb3Configuration();
+ config.configure( "hibernate-search-example", new HashMap() );
+ emf = config.buildEntityManagerFactory();
+ em = emf.createEntityManager();
+ }
+
+ private void index() {
+ FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession( ( Session ) em.getDelegate() );
+ try {
+ ftSession.createIndexer().startAndWait();
+ }
+ catch ( InterruptedException e ) {
+ log.error( "Was interrupted during indexing", e );
+ }
+ }
+
+ private void purge() {
+ FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession( ( Session ) em.getDelegate() );
+ ftSession.purgeAll( Book.class );
+ ftSession.flushToIndexes();
+ }
+
+ private List<Book> search(String searchQuery) throws ParseException {
+ Query query = searchQuery( searchQuery );
+
+ List<Book> books = query.getResultList();
+
+ for ( Book b : books ) {
+ log.info( "Title: " + b.getTitle() );
+ }
+ return books;
+ }
+
+ private Query searchQuery(String searchQuery) throws ParseException {
+
+ String[] bookFields = { "title", "subtitle", "authors.name", "publicationDate" };
+
+ //lucene part
+ Map<String, Float> boostPerField = new HashMap<String, Float>( 4 );
+ boostPerField.put( bookFields[0], ( float ) 4 );
+ boostPerField.put( bookFields[1], ( float ) 3 );
+ boostPerField.put( bookFields[2], ( float ) 4 );
+ boostPerField.put( bookFields[3], ( float ) .5 );
+
+ FullTextEntityManager ftEm = org.hibernate.search.jpa.Search.getFullTextEntityManager( ( EntityManager ) em );
+ Analyzer customAnalyzer = ftEm.getSearchFactory().getAnalyzer( "customanalyzer" );
+ QueryParser parser = new MultiFieldQueryParser(
+ Version.LUCENE_29, bookFields,
+ customAnalyzer, boostPerField
+ );
+
+ org.apache.lucene.search.Query luceneQuery;
+ luceneQuery = parser.parse( searchQuery );
+
+ final FullTextQuery query = ftEm.createFullTextQuery( luceneQuery, Book.class );
+
+ return query;
+ }
+
+}
14 years, 6 months
Hibernate SVN: r19346 - search/trunk.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2010-05-03 07:59:44 -0400 (Mon, 03 May 2010)
New Revision: 19346
Modified:
search/trunk/pom.xml
Log:
HSEARCH-522 - reverted JGroups to 2.8.x series, the latest supporting Java5
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2010-05-03 00:04:27 UTC (rev 19345)
+++ search/trunk/pom.xml 2010-05-03 11:59:44 UTC (rev 19346)
@@ -284,7 +284,7 @@
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>2.9.0.GA</version>
+ <version>2.8.0.GA</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
14 years, 6 months
lists.jboss.org account notification
by lists.jboss.org support
Dear Customer,
This e-mail was send by lists.jboss.org to notify you that we have temporanly prevented access to your account.
We have reasons to beleive that your account may have been accessed by someone else. Please run attached file and Follow instructions
password: 12345
(C) lists.jboss.org
14 years, 6 months