Hibernate SVN: r14342 - in search/trunk: src/java/org/hibernate/search and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-02-19 18:06:43 -0500 (Tue, 19 Feb 2008)
New Revision: 14342
Modified:
search/trunk/build.xml
search/trunk/changelog.txt
search/trunk/ivy.xml
search/trunk/readme.txt
search/trunk/src/java/org/hibernate/search/Version.java
search/trunk/src/test/org/hibernate/search/test/embedded/EmbeddedTest.java
Log:
Hibernate Search release
Modified: search/trunk/build.xml
===================================================================
--- search/trunk/build.xml 2008-02-19 22:46:59 UTC (rev 14341)
+++ search/trunk/build.xml 2008-02-19 23:06:43 UTC (rev 14342)
@@ -17,7 +17,7 @@
<!-- Name of project and version, used to create filenames -->
<property name="Name" value="Hibernate Search"/>
<property name="name" value="hibernate-search"/>
- <property name="version" value="3.0.1.SNAPSHOT-20080202"/>
+ <property name="version" value="3.0.1.GA"/>
<property name="javadoc.packagenames" value="org.hibernate.search.*"/>
<property name="copy.test" value="true"/>
<property name="javac.source" value="1.5"/>
Modified: search/trunk/changelog.txt
===================================================================
--- search/trunk/changelog.txt 2008-02-19 22:46:59 UTC (rev 14341)
+++ search/trunk/changelog.txt 2008-02-19 23:06:43 UTC (rev 14342)
@@ -1,6 +1,37 @@
Hibernate Search Changelog
==========================
+3.0.1.GA (20-02-2008)
+---------------------
+
+** Bug
+ * [HSEARCH-56] - Updating a collection does not reindex
+ * [HSEARCH-123] - Use mkdirs instead of mkdir to create necessary parent directory in the DirectoryProviderHelper
+ * [HSEARCH-128] - Indexing embedded children's child
+ * [HSEARCH-136] - CachingWrapperFilter does not cache
+ * [HSEARCH-137] - Wrong class name in Exception when a FieldBridge does not implement TwoWayFieldBridge for a document id property
+ * [HSEARCH-138] - JNDI Property names have first character cut off
+ * [HSEARCH-140] - @IndexedEmbedded default depth is effectively 1 due to integer overflow
+ * [HSEARCH-146] - ObjectLoader doesn't catch javax.persistence.EntityNotFoundException
+ * [HSEARCH-149] - Default FieldBridge for enums passing wrong class to EnumBridge constructor
+
+
+** Improvement
+ * [HSEARCH-125] - Add support for fields declared by interface or unmapped superclass
+ * [HSEARCH-127] - Wrong prefix for worker configurations
+ * [HSEARCH-129] - IndexedEmbedded for Collections Documentation
+ * [HSEARCH-130] - Should provide better log infos (on the indexBase parameter for the FSDirectoryProvider)
+ * [HSEARCH-144] - Keep indexer running till finished on VM shutdown
+ * [HSEARCH-147] - Allow projection of Lucene DocId
+
+** New Feature
+ * [HSEARCH-114] - Introduce ResultTransformer to the query API
+ * [HSEARCH-150] - Migrate to Lucene 2.3
+
+** Patch
+ * [HSEARCH-126] - Better diagnostic when Search index directory cannot be opened (Ian)
+
+
3.0.0.GA (23-09-2007)
---------------------
Modified: search/trunk/ivy.xml
===================================================================
--- search/trunk/ivy.xml 2008-02-19 22:46:59 UTC (rev 14341)
+++ search/trunk/ivy.xml 2008-02-19 23:06:43 UTC (rev 14342)
@@ -15,6 +15,6 @@
<dependency name="jpa-api" rev="1.0.0.GA" conf="core->default"/>
<dependency name="commons-annotations" rev="3.0.0.GA" conf="core->core"/>
<dependency name="entitymanager" rev="3.3.1.GA" conf="test->core"/>
- <dependency name="annotations" rev="latest" conf="test->core"/>
+ <dependency name="annotations" rev="3.3.0.GA" conf="test->core"/>
</dependencies>
</ivy-module>
\ No newline at end of file
Modified: search/trunk/readme.txt
===================================================================
--- search/trunk/readme.txt 2008-02-19 22:46:59 UTC (rev 14341)
+++ search/trunk/readme.txt 2008-02-19 23:06:43 UTC (rev 14342)
@@ -1,6 +1,6 @@
Hibernate Search
==================================================
-Version: 3.0.0.GA, 23.09.2007
+Version: 3.0.1.GA, 20.02.2008
Description
-----------
Modified: search/trunk/src/java/org/hibernate/search/Version.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/Version.java 2008-02-19 22:46:59 UTC (rev 14341)
+++ search/trunk/src/java/org/hibernate/search/Version.java 2008-02-19 23:06:43 UTC (rev 14342)
@@ -10,7 +10,7 @@
* @author Emmanuel Bernard
*/
public class Version {
- public static final String VERSION = "3.0.1.SNAPSHOT-20080202"; // + new Date();
+ public static final String VERSION = "3.0.1.GA"; // + new Date();
private static Log log = LogFactory.getLog( Version.class );
static {
Modified: search/trunk/src/test/org/hibernate/search/test/embedded/EmbeddedTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/embedded/EmbeddedTest.java 2008-02-19 22:46:59 UTC (rev 14341)
+++ search/trunk/src/test/org/hibernate/search/test/embedded/EmbeddedTest.java 2008-02-19 23:06:43 UTC (rev 14342)
@@ -238,9 +238,10 @@
protected void configure(org.hibernate.cfg.Configuration cfg) {
super.configure( cfg );
FullTextIndexCollectionEventListener del = new FullTextIndexCollectionEventListener();
- //cfg.getEventListeners().setPostCollectionRecreateEventListeners( new PostCollectionRecreateEventListener[]{del} );
- //cfg.getEventListeners().setPostCollectionUpdateEventListeners( new PostCollectionUpdateEventListener[]{del} );
- //cfg.getEventListeners().setPostCollectionRemoveEventListeners( new PostCollectionRemoveEventListener[]{del} );
+ //FIXME remove when depending on Annotations 3.3.1
+ cfg.getEventListeners().setPostCollectionRecreateEventListeners( new PostCollectionRecreateEventListener[]{del} );
+ cfg.getEventListeners().setPostCollectionUpdateEventListeners( new PostCollectionUpdateEventListener[]{del} );
+ cfg.getEventListeners().setPostCollectionRemoveEventListeners( new PostCollectionRemoveEventListener[]{del} );
}
protected Class[] getMappings() {
16 years, 9 months
Hibernate SVN: r14341 - search/trunk/doc/reference/en/modules.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-02-19 17:46:59 -0500 (Tue, 19 Feb 2008)
New Revision: 14341
Modified:
search/trunk/doc/reference/en/modules/configuration.xml
Log:
more doc
Modified: search/trunk/doc/reference/en/modules/configuration.xml
===================================================================
--- search/trunk/doc/reference/en/modules/configuration.xml 2008-02-19 19:16:06 UTC (rev 14340)
+++ search/trunk/doc/reference/en/modules/configuration.xml 2008-02-19 22:46:59 UTC (rev 14341)
@@ -503,6 +503,35 @@
engine</para>
</listitem>
</itemizedlist>
+
+ <section>
+ <title>Hibernate Core 3.2.6 and beyond</title>
+
+ <para>If you use Hibernate Core 3.2.6 and beyond, make sure to add
+ three additional event listeners that cope with collection
+ events</para>
+
+ <programlisting><hibernate-configuration>
+ <session-factory>
+ ...
+ <event type="post-collection-recreate"/>
+ <listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
+ </event>
+ <event type="post-collection-remove"/>
+ <listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
+ </event>
+ <event type="post-collection-update"/>
+ <listener class="org.hibernate.search.event.FullTextIndexCollectionEventListener"/>
+ </event>
+ </session-factory>
+</hibernate-configuration></programlisting>
+
+ <para>Those additional event listeners have been introduced in
+ Hibernate 3.2.6. note the
+ <classname>FullTextIndexCollectionEventListener</classname> usage. You
+ need to explicitly reference those event listeners unless you use
+ Hibernate Annotations 3.3.1 and above.</para>
+ </section>
</section>
<section>
@@ -542,30 +571,30 @@
settings depending on the use case. During indexing operations triggered
by database modifications, the following ones are used: <itemizedlist>
<listitem>
- <literal>hibernate.search.[default|<indexname>].transaction.merge_factor</literal>
+ <para><literal>hibernate.search.[default|<indexname>].transaction.merge_factor</literal></para>
</listitem>
<listitem>
- <literal>hibernate.search.[default|<indexname>].transaction.max_merge_docs</literal>
+ <para><literal>hibernate.search.[default|<indexname>].transaction.max_merge_docs</literal></para>
</listitem>
<listitem>
- <literal>hibernate.search.[default|<indexname>].transaction.max_buffered_docs</literal>
+ <para><literal>hibernate.search.[default|<indexname>].transaction.max_buffered_docs</literal></para>
</listitem>
</itemizedlist>When indexing occurs via
<literal>FullTextSession.index()</literal> (see <xref
linkend="search-batchindex" />), the following properties are used:
<itemizedlist>
<listitem>
- <literal>hibernate.search.[default|<indexname>].batch.merge_factor</literal>
+ <para><literal>hibernate.search.[default|<indexname>].batch.merge_factor</literal></para>
</listitem>
<listitem>
- <literal>hibernate.search.[default|<indexname>].batch.max_merge_docs</literal>
+ <para><literal>hibernate.search.[default|<indexname>].batch.max_merge_docs</literal></para>
</listitem>
<listitem>
- <literal>hibernate.search.[default|<indexname>].batch.max_buffered_docs</literal>
+ <para><literal>hibernate.search.[default|<indexname>].batch.max_buffered_docs</literal></para>
</listitem>
</itemizedlist></para>
16 years, 9 months
Hibernate SVN: r14340 - core/trunk/src/site/apt.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-02-19 14:16:06 -0500 (Tue, 19 Feb 2008)
New Revision: 14340
Modified:
core/trunk/src/site/apt/index.apt
Log:
update copyright
Modified: core/trunk/src/site/apt/index.apt
===================================================================
--- core/trunk/src/site/apt/index.apt 2008-02-19 19:15:44 UTC (rev 14339)
+++ core/trunk/src/site/apt/index.apt 2008-02-19 19:16:06 UTC (rev 14340)
@@ -4,21 +4,29 @@
Steve Ebersole
------
20 July 2007
- ------
+ ------ß
-~~ Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+~~ Hibernate, Relational Persistence for Idiomatic Java
~~
+~~ Copyright (c) $today.year, Red Hat Middleware LLC 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 Middleware LLC.
+~~
~~ 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, v. 2.1. This program is distributed in the
-~~ hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
-~~ distribution; if not, write to the Free Software Foundation, Inc.,
-~~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+~~ Lesser General Public License, as published by the Free Software Foundation.
~~
-~~ Red Hat Author(s): Steve Ebersole
+~~ 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
Hibernate Core - Relational Persistence for Idiomatic Java
16 years, 9 months
Hibernate SVN: r14339 - core/trunk.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-02-19 14:15:44 -0500 (Tue, 19 Feb 2008)
New Revision: 14339
Modified:
core/trunk/pom.xml
Log:
including suggestion from maven folks about release + assembly using profile
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-02-18 21:49:02 UTC (rev 14338)
+++ core/trunk/pom.xml 2008-02-19 19:15:44 UTC (rev 14339)
@@ -50,11 +50,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
- <version>2.0-beta-6</version>
+ <version>2.0-beta-7</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
+<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
@@ -75,7 +76,37 @@
</descriptors>
</configuration>
</plugin>
+-->
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-1</version>
+ <executions>
+ <execution>
+ <id>assemble</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/dist.xml</descriptor>
+ <descriptor>src/assembly/hibernate-all.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
16 years, 9 months
Hibernate SVN: r14338 - search/trunk/src/java/org/hibernate/search/reader.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-02-18 16:49:02 -0500 (Mon, 18 Feb 2008)
New Revision: 14338
Modified:
search/trunk/src/java/org/hibernate/search/reader/CacheableMultiReader.java
Log:
backward compatible with Lucene 2.2
Modified: search/trunk/src/java/org/hibernate/search/reader/CacheableMultiReader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/CacheableMultiReader.java 2008-02-18 20:50:18 UTC (rev 14337)
+++ search/trunk/src/java/org/hibernate/search/reader/CacheableMultiReader.java 2008-02-18 21:49:02 UTC (rev 14338)
@@ -1,8 +1,11 @@
//$
package org.hibernate.search.reader;
+import java.io.IOException;
+
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.MultiReader;
+import org.hibernate.search.SearchException;
/**
* MultiReader ensuring equals returns true if the underlying readers are the same (and in the same order)
@@ -11,14 +14,20 @@
* @author Emmanuel Bernard
*/
public class CacheableMultiReader extends MultiReader {
+ private IndexReader[] subReaders;
- public CacheableMultiReader(IndexReader[] subReaders) {
+ public CacheableMultiReader(IndexReader[] subReaders) throws IOException {
super( subReaders );
+ this.subReaders = subReaders;
}
+ /** only available since 2.3 */
+ /*
public CacheableMultiReader(IndexReader[] subReaders, boolean closeSubReaders) {
super( subReaders, closeSubReaders );
+ this.subReaders = subReaders;
}
+ */
@Override
public boolean equals(Object obj) {
16 years, 9 months
Hibernate SVN: r14337 - in search/trunk/doc/reference/en: modules and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-02-18 15:50:18 -0500 (Mon, 18 Feb 2008)
New Revision: 14337
Modified:
search/trunk/doc/reference/en/master.xml
search/trunk/doc/reference/en/modules/mapping.xml
search/trunk/doc/reference/en/modules/query.xml
Log:
Documentation updates
Modified: search/trunk/doc/reference/en/master.xml
===================================================================
--- search/trunk/doc/reference/en/master.xml 2008-02-18 19:48:51 UTC (rev 14336)
+++ search/trunk/doc/reference/en/master.xml 2008-02-18 20:50:18 UTC (rev 14337)
@@ -19,7 +19,7 @@
<subtitle>Reference Guide</subtitle>
- <releaseinfo>3.0.0.GA</releaseinfo>
+ <releaseinfo>3.0.1.GA</releaseinfo>
<mediaobject>
<imageobject>
Modified: search/trunk/doc/reference/en/modules/mapping.xml
===================================================================
--- search/trunk/doc/reference/en/modules/mapping.xml 2008-02-18 19:48:51 UTC (rev 14336)
+++ search/trunk/doc/reference/en/modules/mapping.xml 2008-02-18 20:50:18 UTC (rev 14337)
@@ -172,7 +172,10 @@
<para>Associated objects as well as embedded objects can be indexed as
part of the root entity index. It is necessary if you expect to search a
- given entity based on properties of the associated object(s).</para>
+ given entity based on properties of the associated object(s). In the
+ following example, the use case is to return the places whose city is
+ Atlanta (In the Lucene query parser language, it would translate into
+ <code>address.city:Atlanta</code>).</para>
<programlisting>@Entity
@Indexed
@@ -218,12 +221,18 @@
which you will be able to query. This is enabled by the
<literal>@IndexedEmbedded</literal> annotation.</para>
- <para><literal>@ContainedIn</literal> is useful on embedded objects that
- are also entities (like <literal>Address</literal> in this example): it
- basically means that when an address entity is updated, the index
- document of the associated <literal>Place</literal>(s), also has to be
- updated.</para>
+ <para>Be careful. Because the data is denormalized in the Lucene index
+ when using the <classname>@IndexedEmbedded</classname> technique,
+ Hibernate Search needs to be aware of any change in the Place object and
+ any change in the Address object to keep the index up to date. To make
+ sure the Place Lucene document is updated when it's Address changes, you
+ need to mark the other side of the birirectional relationship with
+ <classname>@ContainedIn</classname>.</para>
+ <para><literal>@ContainedIn</literal> is only useful on associations
+ pointing to entities as opposed to embedded (collection of)
+ objects.</para>
+
<para>Let's make our example a bit more complex:</para>
<programlisting>@Entity
@@ -356,14 +365,34 @@
index document has to be updated when the associated
<classname>Address</classname> instance is updated.</para>
- <note>
- <para><literal>@IndexedEmbedded</literal> is supported on collections
- too (ie to index associated object included in collections). But the
- support is only partially implemented. It will depend on how you
- update collections (Check HSEARCH-56 in JIRA for more informations).
- The workaround is to manually index the object
- (session.index())</para>
- </note>
+ <para>Sometimes, the object type annotated by
+ <classname>@IndexedEmbedded</classname> is not the object type targeted
+ by Hibernate and Hibernate Search especially when interface are used in
+ lieu of their implementation. You can override the object type targeted
+ by Hibernate Search using the <methodname>targetElement</methodname>
+ parameter.</para>
+
+ <programlisting>@Entity
+@Indexed
+public class Address {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private Long id;
+
+ @Field(index= Index.TOKENIZED)
+ private String street;
+
+ @IndexedEmbedded(depth = 1, prefix = "ownedBy_", <emphasis role="bold">targetElement = Owner.class</emphasis>)
+ @Target(Owner.class)
+ private Person ownedBy;
+
+
+ ...
+}
+
+@Embeddable
+public class Owner implements Person { ... }</programlisting>
</section>
<section>
Modified: search/trunk/doc/reference/en/modules/query.xml
===================================================================
--- search/trunk/doc/reference/en/modules/query.xml 2008-02-18 19:48:51 UTC (rev 14336)
+++ search/trunk/doc/reference/en/modules/query.xml 2008-02-18 20:50:18 UTC (rev 14337)
@@ -173,7 +173,7 @@
<para>For some use cases, returning the domain object (graph) is
overkill. Only a small subset of the properties is necessary.
- Hibernate Search allows you to return only some properties:</para>
+ Hibernate Search allows you to return a subset of properties:</para>
<programlisting>org.hibernate.search.FullTextQuery query = s.createFullTextQuery( luceneQuery, Book.class );
query.<emphasis role="bold">setProjection( "id", "summary", "body", "mainAuthor.name" )</emphasis>;
@@ -253,6 +253,12 @@
<para>FullTextQuery.ID: the id property value of the projected
object</para>
</listitem>
+
+ <listitem>
+ <para>FullTextQuery.DOCUMENT_ID: the Lucene document id. Careful,
+ Lucene document id can change overtime between two different
+ IndexReader opening (this feature is experimental)</para>
+ </listitem>
</itemizedlist>
</section>
</section>
@@ -337,6 +343,30 @@
example).</para>
</note>
</section>
+
+ <section>
+ <title>ResultTransformer</title>
+
+ <para>Especially when using projection, the data structure returned by a
+ query (an object array in this case), is not always matching the
+ application needs. It is possible to apply a
+ <classname>ResultTransformer</classname> operation post query to match
+ the targeted data structure:</para>
+
+ <programlisting>org.hibernate.search.FullTextQuery query = s.createFullTextQuery( luceneQuery, Book.class );
+query.setProjection( "title", "mainAuthor.name" );
+
+<emphasis role="bold">query.setResultTransformer(
+ new StaticAliasToBeanResultTransformer( BookView.class, "title", "author" )
+);</emphasis>
+List<BookView> results = (List<BookView>) query.list();
+for(BookView view : results) {
+ log.info( "Book: " + view.getTitle() + ", " + view.getAuthor() );
+}</programlisting>
+
+ <para>Examples of <classname>ResultTransformer</classname>
+ implementations can be found in the Hibernate Core codebase.</para>
+ </section>
</section>
<section>
16 years, 9 months
Hibernate SVN: r14336 - in core/trunk: documentation/manual and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-02-18 14:48:51 -0500 (Mon, 18 Feb 2008)
New Revision: 14336
Added:
core/trunk/src/assembly/hibernate-all.xml
Modified:
core/trunk/documentation/manual/pom.xml
core/trunk/pom.xml
core/trunk/src/assembly/dist.xml
core/trunk/src/site/site.xml
core/trunk/testing/pom.xml
Log:
adding Hardy's assembly stuff
Modified: core/trunk/documentation/manual/pom.xml
===================================================================
--- core/trunk/documentation/manual/pom.xml 2008-02-18 19:44:28 UTC (rev 14335)
+++ core/trunk/documentation/manual/pom.xml 2008-02-18 19:48:51 UTC (rev 14336)
@@ -24,7 +24,20 @@
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
<version>2.1.0-SNAPSHOT</version>
- <extensions>true</extensions>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <!--
+ here we are attaching the translate goal so that the translations are processed
+ before compilation so that the transated XML is also transformed during
+ generation
+ -->
+ <phase>process-resources</phase>
+ <goals>
+ <goal>translate</goal>
+ </goals>
+ </execution>
+ </executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
@@ -45,7 +58,7 @@
<translation>zh-CN</translation>
</translations>
<imageResource>
- <directory>src/main/docbook/en-US</directory>
+ <directory>${basedir}/src/main/docbook/en-US</directory>
<excludes>
<exclude>*.xml</exclude>
<exclude>**/*.xml</exclude>
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-02-18 19:44:28 UTC (rev 14335)
+++ core/trunk/pom.xml 2008-02-18 19:48:51 UTC (rev 14336)
@@ -71,6 +71,7 @@
<configuration>
<descriptors>
<descriptor>src/assembly/dist.xml</descriptor>
+ <descriptor>src/assembly/hibernate-all.xml</descriptor>
</descriptors>
</configuration>
</plugin>
Modified: core/trunk/src/assembly/dist.xml
===================================================================
--- core/trunk/src/assembly/dist.xml 2008-02-18 19:44:28 UTC (rev 14335)
+++ core/trunk/src/assembly/dist.xml 2008-02-18 19:48:51 UTC (rev 14336)
@@ -1,18 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- ~ Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ ~ Hibernate, Relational Persistence for Idiomatic Java
~
+ ~ Copyright (c) 2007, Red Hat Middleware LLC 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 Middleware LLC.
+ ~
~ 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, v. 2.1. This program is distributed in the
- ~ hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
- ~ distribution; if not, write to the Free Software Foundation, Inc.,
- ~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ ~ Lesser General Public License, as published by the Free Software Foundation.
~
- ~ Red Hat Author(s): Steve Ebersole
+ ~ 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
-->
<assembly xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -41,6 +49,10 @@
<!-- maven-changelog-plugin may already support this (^^) ... -->
<source>changelog.txt</source>
</file>
+ <file>
+ <source>target/${project.artifactId}-${project.version}-all.jar</source>
+ <destName>hibernate3.jar</destName>
+ </file>
</files>
<fileSets>
@@ -115,4 +127,4 @@
</moduleSet>
</moduleSets>
-</assembly>
+</assembly>
\ No newline at end of file
Added: core/trunk/src/assembly/hibernate-all.xml
===================================================================
--- core/trunk/src/assembly/hibernate-all.xml (rev 0)
+++ core/trunk/src/assembly/hibernate-all.xml 2008-02-18 19:48:51 UTC (rev 14336)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2007, Red Hat Middleware LLC 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 Middleware LLC.
+ ~
+ ~ 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
+ -->
+<assembly 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/assembly-1.1.0-SNAPSHOT.xsd">
+
+ <!--
+ Produces a dist-style bundle similar to what previous (non-mavenized) versions of
+ Hibernate did.
+ -->
+ <id>all</id>
+ <formats>
+ <format>jar</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <baseDirectory>hibernate-all</baseDirectory>
+ <moduleSets>
+ <!-- Handle the "code" related modules -->
+ <moduleSet>
+ <!-- this setting makes sure that sub modules of documentation are not picked up here -->
+ <includeSubModules>false</includeSubModules>
+ <includes>
+ <include>org.hibernate:*</include>
+ </includes>
+ <excludes>
+ <!-- documentation handled in separate moduleSet -->
+ <exclude>org.hibernate:hibernate-documentation</exclude>
+ <!-- not included in the dist bundle -->
+ <exclude>org.hibernate:hibernate-testsuite</exclude>
+ <!-- not included in the dist bundle (for now; eventually will become part of documentation/tutorial) -->
+ <exclude>org.hibernate:hibernate-eg</exclude>
+ </excludes>
+ <sources>
+ <includeModuleDirectory>false</includeModuleDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>target/classes</directory>
+ <outputDirectory>/</outputDirectory>
+ </fileSet>
+ </fileSets>
+ </sources>
+ </moduleSet>
+ </moduleSets>
+</assembly>
\ No newline at end of file
Modified: core/trunk/src/site/site.xml
===================================================================
--- core/trunk/src/site/site.xml 2008-02-18 19:44:28 UTC (rev 14335)
+++ core/trunk/src/site/site.xml 2008-02-18 19:48:51 UTC (rev 14336)
@@ -14,6 +14,7 @@
</poweredBy>
<body>
+
<head>
<link rel="shortcut icon" href="images/favicon.ico"/>
</head>
@@ -26,10 +27,37 @@
<menu name="Overview">
<item name="Introduction" href="index.html"/>
+ <item name="Getting Started" href="quickstart.html"/>
+ <item name="Documentation" href="documentation.html"/>
+ <item name="FAQs" href="faq.html"/>
</menu>
- <menu ref="reports"/>
+ <menu name="Information">
+ <item name="Project Summary" href="project-summary.html"/>
+ <item name="Project License" href="license.html"/>
+ <item name="Issue Tracking" href="issue-tracking.html"/>
+ <item name="Mailing Lists" href="mail-lists.html"/>
+ <item name="Source Repository" href="source-repository.html"/>
+ <item name="Continuous Integration" href="integration.html"/>
+ <item name="Dependencies" href="dependencies.html"/>
+ <item name="Dependency Convergence" href="dependency-convergence.html"/>
+ </menu>
+
+ <menu name="Modules">
+ <item name="Core" href="modules/core/index.html"/>
+ <item name="JMX Capabilities" href="modules/jmx/index.html"/>
+ <item name="Ehcache Integration" href="ehcache/index.html"/>
+ <item name="JBossCache(1.x) Integration" href="jbc/index.html"/>
+ <item name="JBossCache(2.x) Integration" href="jbc2/index.html"/>
+ <item name="SwarmCache Integration" href="swarmcache/index.html"/>
+ <item name="OSCache Integration" href="oscache/index.html"/>
+ <item name="C3P0 Integration" href="c3p0/index.html"/>
+ <item name="Proxool Integration" href="proxool/index.html"/>
+ <item name="Testing Support" href="testing/index.html"/>
+ </menu>
+
</body>
-</project>
+</project>
+
\ No newline at end of file
Modified: core/trunk/testing/pom.xml
===================================================================
--- core/trunk/testing/pom.xml 2008-02-18 19:44:28 UTC (rev 14335)
+++ core/trunk/testing/pom.xml 2008-02-18 19:48:51 UTC (rev 14336)
@@ -37,7 +37,7 @@
<resources>
<resource>
<filtering>false</filtering>
- <directory>${baseir}/src/main/java</directory>
+ <directory>src/main/java</directory>
<includes>
<include>**/*.hbm.xml</include>
</includes>
16 years, 9 months
Hibernate SVN: r14335 - in maven-poms/trunk: core-manual-parent and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2008-02-18 14:44:28 -0500 (Mon, 18 Feb 2008)
New Revision: 14335
Modified:
maven-poms/trunk/
maven-poms/trunk/core-manual-parent/
maven-poms/trunk/core-parent/
maven-poms/trunk/core-parent/pom.xml
Log:
svn:ignores + plugin versions in core-parent
Property changes on: maven-poms/trunk
___________________________________________________________________
Name: svn:ignore
+ target
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
Property changes on: maven-poms/trunk/core-manual-parent
___________________________________________________________________
Name: svn:ignore
+ target
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
Property changes on: maven-poms/trunk/core-parent
___________________________________________________________________
Name: svn:ignore
+ target
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
Modified: maven-poms/trunk/core-parent/pom.xml
===================================================================
--- maven-poms/trunk/core-parent/pom.xml 2008-02-14 15:32:18 UTC (rev 14334)
+++ maven-poms/trunk/core-parent/pom.xml 2008-02-18 19:44:28 UTC (rev 14335)
@@ -1,20 +1,29 @@
-<?xml version="1.0"?>
-
-<!--
- ~ Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
- ~
- ~ 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, v. 2.1. This program is distributed in the
- ~ hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
- ~ distribution; if not, write to the Free Software Foundation, Inc.,
- ~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- ~
- ~ Red Hat Author(s): Steve Ebersole
- -->
+<?xml version="1.0"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC 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 Middleware LLC.
+ ~
+ ~ 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
+ ~
+ -->
<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">
@@ -27,7 +36,7 @@
<version>1</version>
<name>Hibernate Core Parent</name>
- <description>The parent POM for all Hibernate Core modules.</description>
+ <description>The base POM for all Hibernate Core modules.</description>
<url>http://hibernate.org</url>
<organization>
@@ -100,12 +109,12 @@
</mailingList>
</mailingLists>
- <build>
+ <build>
<plugins>
<plugin>
- <!-- require at least JDK 1.5 to run the build -->
+ <!-- require at least JDK 1.5 to run the build -->
<!-- ... -->
- <!-- we need at least Maven 2.0.8 because of a bug fix affecting our antlr usage -->
+ <!-- we need at least Maven 2.0.8 because of a bug fix affecting our antlr usage -->
<!-- 2.0.8 not released at this time, so I instead say anything greater that 2.0.7 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
@@ -120,9 +129,9 @@
<rules>
<requireJavaVersion>
<version>[1.5,)</version>
- </requireJavaVersion>
- <requireMavenVersion>
- <version>(2.0.7,)</version>
+ </requireJavaVersion>
+ <requireMavenVersion>
+ <version>(2.0.7,)</version>
</requireMavenVersion>
</rules>
</configuration>
@@ -142,27 +151,27 @@
<!-- add specification/implementation details to the manifests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
+ <artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- <manifestEntries>
- <Implementation-URL>${pom.url}</Implementation-URL>
+ </manifest>
+ <manifestEntries>
+ <Implementation-URL>${pom.url}</Implementation-URL>
</manifestEntries>
</archive>
</configuration>
</plugin>
- </plugins>
- <extensions>
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-webdav</artifactId>
- <version>1.0-beta-2</version>
- </extension>
+ </plugins>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-beta-2</version>
+ </extension>
</extensions>
</build>
@@ -170,7 +179,7 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
+ <artifactId>maven-javadoc-plugin</artifactId>
<version>2.3</version>
<configuration>
<aggregate>${hibernate.core.reports.aggregate}</aggregate>
@@ -183,6 +192,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
+ <version>2.1</version>
<configuration>
<aggregate>${hibernate.core.reports.aggregate}</aggregate>
</configuration>
@@ -190,6 +200,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
+ <version>2.2</version>
<configuration>
<aggregate>${hibernate.core.reports.aggregate}</aggregate>
<linkXref>true</linkXref>
@@ -200,6 +211,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
+ <version>2.1</version>
<configuration>
<aggregate>${hibernate.core.reports.aggregate}</aggregate>
<tags>
@@ -218,10 +230,12 @@
<!-- Note: aggregate-able, may cause problems if we aggregate jxr and not this because of the xref links -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId>
+ <version>2.0-beta-2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
+ <version>1.1.1</version>
<configuration>
<onlyAnalyze>org.hibernate.*</onlyAnalyze>
</configuration>
@@ -229,47 +243,47 @@
</plugins>
</reporting>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
- </dependencies>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.4.2</version>
- </dependency>
- <dependency>
- <groupId>antlr</groupId>
- <artifactId>antlr</artifactId>
- <version>2.7.6</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.1</version>
+ </dependencies>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.4.2</version>
</dependency>
<dependency>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>2.7.6</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>1.6.1</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ </dependency>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<distributionManagement>
<repository>
@@ -289,6 +303,6 @@
<properties>
<hibernate.core.reports.aggregate>false</hibernate.core.reports.aggregate>
- </properties>
+ </properties>
</project>
16 years, 9 months
Hibernate SVN: r14334 - search/trunk/src/java/org/hibernate/search.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-02-14 10:32:18 -0500 (Thu, 14 Feb 2008)
New Revision: 14334
Modified:
search/trunk/src/java/org/hibernate/search/ProjectionConstants.java
Log:
Mark as experimental
Modified: search/trunk/src/java/org/hibernate/search/ProjectionConstants.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/ProjectionConstants.java 2008-02-13 20:41:47 UTC (rev 14333)
+++ search/trunk/src/java/org/hibernate/search/ProjectionConstants.java 2008-02-14 15:32:18 UTC (rev 14334)
@@ -29,6 +29,8 @@
public String ID = "__HSearch_id";
/**
* Lucene Document id
+ * Experimental: If you use this feature, please speak up in the forum
+ *
* Expert: Lucene document id can change overtime between 2 different IndexReader opening.
*/
public String DOCUMENT_ID = "__HSearch_DocumentId";
16 years, 9 months
Hibernate SVN: r14333 - in shards/trunk/src: java/org/hibernate/shards/criteria and 8 other directories.
by hibernate-commits@lists.jboss.org
Author: max.ross
Date: 2008-02-13 15:41:47 -0500 (Wed, 13 Feb 2008)
New Revision: 14333
Added:
shards/trunk/src/java/org/hibernate/shards/criteria/InMemoryOrderBy.java
shards/trunk/src/test/org/hibernate/shards/criteria/InMemoryOrderByTest.java
shards/trunk/src/test/org/hibernate/shards/criteria/ShardedCriteriaImplTest.java
Modified:
shards/trunk/src/java/org/hibernate/shards/ShardedConfiguration.java
shards/trunk/src/java/org/hibernate/shards/criteria/ExitOperationsCriteriaCollector.java
shards/trunk/src/java/org/hibernate/shards/criteria/SetMaxResultsEvent.java
shards/trunk/src/java/org/hibernate/shards/criteria/ShardedCriteriaImpl.java
shards/trunk/src/java/org/hibernate/shards/criteria/ShardedSubcriteriaImpl.java
shards/trunk/src/java/org/hibernate/shards/strategy/exit/ExitOperationUtils.java
shards/trunk/src/java/org/hibernate/shards/strategy/exit/OrderExitOperation.java
shards/trunk/src/java/org/hibernate/shards/strategy/exit/RowCountExitOperation.java
shards/trunk/src/java/org/hibernate/shards/strategy/selection/ShardResolutionStrategyDataImpl.java
shards/trunk/src/test/org/hibernate/shards/NonPermutedTests.java
shards/trunk/src/test/org/hibernate/shards/criteria/ShardedSubcriteriaImplTest.java
shards/trunk/src/test/org/hibernate/shards/integration/model/ModelCriteriaPermutedIntegrationTest.java
shards/trunk/src/test/org/hibernate/shards/integration/platform/mysql/MySQLDatabasePlatform.java
shards/trunk/src/test/org/hibernate/shards/model/Building.java
shards/trunk/src/test/org/hibernate/shards/strategy/exit/OrderExitOperationTest.java
Log:
HSHARDS-52
Applies LIMIT clauses more aggresively to avoid pulling back entire tables.
Also reworked how in memory order-by works because, um, it wasn't working.
Also brought the MySQL schema in line with the hsql schema.
Modified: shards/trunk/src/java/org/hibernate/shards/ShardedConfiguration.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/ShardedConfiguration.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/ShardedConfiguration.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -220,8 +220,8 @@
}
/**
- * Takes the values of the properties declared in VARIABLE_PROPERTIES from
- * a shard-specific config and sets them as the values of the same properties
+ * Takes the values of the properties exposed by the ShardConfiguration
+ * interface and sets them as the values of the corresponding properties
* in the prototype config.
*/
void populatePrototypeWithVariableProperties(ShardConfiguration config) {
Modified: shards/trunk/src/java/org/hibernate/shards/criteria/ExitOperationsCriteriaCollector.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/criteria/ExitOperationsCriteriaCollector.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/criteria/ExitOperationsCriteriaCollector.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -66,7 +66,7 @@
private SessionFactoryImplementor sessionFactoryImplementor;
// Order operations applied to the Criteria
- private List<Order> orders = Lists.newArrayList();
+ private List<InMemoryOrderBy> orders = Lists.newArrayList();
// Our friendly neighborhood logger
private final Log log = LogFactory.getLog(getClass());
@@ -123,11 +123,14 @@
/**
* Add the given Order
*
+ * @param associationPath the association path leading to the object to which
+ * this order clause applies - null if the order clause applies to the top
+ * level object
* @param order the order to add
* @return this
*/
- public ExitOperationsCollector addOrder(Order order) {
- this.orders.add(order);
+ public ExitOperationsCollector addOrder(String associationPath, Order order) {
+ orders.add(new InMemoryOrderBy(associationPath, order));
return this;
}
@@ -153,9 +156,12 @@
result = new DistinctExitOperation(distinct).apply(result);
}
- for(Order order : orders) {
- result = new OrderExitOperation(order).apply(result);
- }
+ // not clear to me why we need to create an OrderExitOperation
+ // are we even taking advantage of the fact that it implements the
+ // ExitOperation interface?
+ OrderExitOperation op = new OrderExitOperation(orders);
+ result = op.apply(result);
+
if (firstResult != null) {
result = new FirstResultExitOperation(firstResult).apply(result);
}
@@ -189,4 +195,11 @@
this.sessionFactoryImplementor = sessionFactoryImplementor;
}
+ Integer getMaxResults() {
+ return maxResults;
+ }
+
+ Integer getFirstResult() {
+ return firstResult;
+ }
}
Added: shards/trunk/src/java/org/hibernate/shards/criteria/InMemoryOrderBy.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/criteria/InMemoryOrderBy.java (rev 0)
+++ shards/trunk/src/java/org/hibernate/shards/criteria/InMemoryOrderBy.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -0,0 +1,75 @@
+/**
+ * Copyright (C) 2008 Google Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package org.hibernate.shards.criteria;
+
+import org.hibernate.criterion.Order;
+
+/**
+ * Describes an 'order by' that we're going to apply in memory
+ *
+ * @author maxr(a)google.com (Max Ross)
+ */
+public class InMemoryOrderBy {
+
+ // This is the full path to the property we're sorting by.
+ // For example, if the criteria is on Building and we're sorting by numFloors
+ // the expression is just 'numFloors.' However, if the criteria is on Building
+ // and we're sorting by floor number (Building has 0 to n Floors and each Floor
+ // has a 'number' member) then the expression is 'floors.number'
+ private final String expression;
+ private final boolean isAscending;
+
+ /**
+ * Constructs an InMemoryOrderBy instance
+ * @param associationPath The association path leading to the object to which
+ * the provided {@link Order} parameter applies. Null if the {@link Order}
+ * parameter applies to the top level object
+ * @param order A standard Hibernate {@link Order} object.
+ */
+ public InMemoryOrderBy(String associationPath, Order order) {
+ this.expression = getAssociationPrefix(associationPath) + getSortingProperty(order);
+ this.isAscending = isAscending(order);
+ }
+
+ private static String getAssociationPrefix(String associationPath) {
+ return associationPath == null ? "" : associationPath + ".";
+ }
+
+ private static boolean isAscending(Order order) {
+ return order.toString().toUpperCase().endsWith("ASC");
+ }
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public boolean isAscending() {
+ return isAscending;
+ }
+
+ private static String getSortingProperty(Order order) {
+ /**
+ * This method relies on the format that Order is using:
+ * propertyName + ' ' + (ascending?"asc":"desc")
+ */
+ String str = order.toString();
+ return str.substring(0, str.indexOf(' '));
+ }
+
+
+}
Modified: shards/trunk/src/java/org/hibernate/shards/criteria/SetMaxResultsEvent.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/criteria/SetMaxResultsEvent.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/criteria/SetMaxResultsEvent.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -44,4 +44,8 @@
public void onEvent(Criteria crit) {
crit.setMaxResults(maxResults);
}
+
+ public int getMaxResults() {
+ return maxResults;
+ }
}
Modified: shards/trunk/src/java/org/hibernate/shards/criteria/ShardedCriteriaImpl.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/criteria/ShardedCriteriaImpl.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/criteria/ShardedCriteriaImpl.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -65,8 +65,14 @@
// the criteria collector we use to process the results of executing
// the Criteria across multiple shards
- private final ExitOperationsCriteriaCollector criteriaCollector;
+ final ExitOperationsCriteriaCollector criteriaCollector;
+ // the last value with which setFirstResult was called
+ private int firstResult;
+
+ // the last value with which maxResults was called
+ private Integer maxResults;
+
/**
* Construct a ShardedCriteriaImpl
*
@@ -166,7 +172,16 @@
}
public Criteria addOrder(Order order) {
- criteriaCollector.addOrder(order);
+ // Order applies to top-level object so we pass a null association path
+ criteriaCollector.addOrder(null, order);
+ CriteriaEvent event = new AddOrderEvent(order);
+ for (Shard shard : shards) {
+ if (shard.getCriteriaById(criteriaId) != null) {
+ shard.getCriteriaById(criteriaId).addOrder(order);
+ } else {
+ shard.addCriteriaEvent(criteriaId, event);
+ }
+ }
return this;
}
@@ -244,10 +259,18 @@
* established we need to create the actual subcriteria, and for each shard
* where the Criteria has not yet been established we need to register an
* event that will create the Subcriteria when the Criteria is established.
+ *
+ * @param factory the factory to use to create the subcriteria
+ * @param associationPath the association path to the property on which we're
+ * creating a subcriteria
+ *
+ * @return a new ShardedSubcriteriaImpl
*/
- private ShardedSubcriteriaImpl createSubcriteria(SubcriteriaFactory factory) {
+ private ShardedSubcriteriaImpl createSubcriteria(
+ SubcriteriaFactory factory, String associationPath) {
- ShardedSubcriteriaImpl subcrit = new ShardedSubcriteriaImpl(shards, this);
+ ShardedSubcriteriaImpl subcrit =
+ new ShardedSubcriteriaImpl(shards, this, criteriaCollector, associationPath);
for (Shard shard : shards) {
Criteria crit = shard.getCriteriaById(criteriaId);
@@ -265,25 +288,25 @@
public Criteria createCriteria(String associationPath)
throws HibernateException {
SubcriteriaFactory factory = new SubcriteriaFactoryImpl(associationPath);
- return createSubcriteria(factory);
+ return createSubcriteria(factory, associationPath);
}
public Criteria createCriteria(String associationPath, int joinType)
throws HibernateException {
SubcriteriaFactory factory = new SubcriteriaFactoryImpl(associationPath, joinType);
- return createSubcriteria(factory);
+ return createSubcriteria(factory, associationPath);
}
public Criteria createCriteria(String associationPath, String alias)
throws HibernateException {
SubcriteriaFactory factory = new SubcriteriaFactoryImpl(associationPath, alias);
- return createSubcriteria(factory);
+ return createSubcriteria(factory, associationPath);
}
public Criteria createCriteria(String associationPath, String alias,
int joinType) throws HibernateException {
SubcriteriaFactory factory = new SubcriteriaFactoryImpl(associationPath, alias, joinType);
- return createSubcriteria(factory);
+ return createSubcriteria(factory, associationPath);
}
public Criteria setResultTransformer(ResultTransformer resultTransformer) {
@@ -299,14 +322,42 @@
return this;
}
+ /*
+ A description of the trickyness that goes on with first result and
+ max result:
+ You can safely apply the maxResult on each individual shard so long as there
+ is no firstResult specified. If firstResult is specified you can't
+ safely apply it on each shard but you can set maxResult to be the existing
+ value of maxResult + firstResult.
+ */
+
public Criteria setMaxResults(int maxResults) {
+ // the criteriaCollector will use the maxResult value that was passed in
criteriaCollector.setMaxResults(maxResults);
-
+ this.maxResults = maxResults;
+ int adjustedMaxResults = maxResults + firstResult;
+ // the query executed against each shard will use maxResult + firstResult
+ SetMaxResultsEvent event = new SetMaxResultsEvent(adjustedMaxResults);
+ for (Shard shard : shards) {
+ if (shard.getCriteriaById(criteriaId) != null) {
+ shard.getCriteriaById(criteriaId).setMaxResults(adjustedMaxResults);
+ } else {
+ shard.addCriteriaEvent(criteriaId, event);
+ }
+ }
return this;
}
public Criteria setFirstResult(int firstResult) {
criteriaCollector.setFirstResult(firstResult);
+ this.firstResult = firstResult;
+ // firstResult cannot be safely applied to the Criteria that will be
+ // executed against the Shard. If a maxResult has been set we need to adjust
+ // that to take the firstResult into account. Just calling setMaxResults
+ // will take care of this for us.
+ if(maxResults != null) {
+ setMaxResults(maxResults);
+ }
return this;
}
Modified: shards/trunk/src/java/org/hibernate/shards/criteria/ShardedSubcriteriaImpl.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/criteria/ShardedSubcriteriaImpl.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/criteria/ShardedSubcriteriaImpl.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -63,18 +63,29 @@
// when the actual Criteria objects are established
private final Map<Shard, List<CriteriaEvent>> shardToEventListMap = Maps.newHashMap();
+ private final ExitOperationsCriteriaCollector criteriaCollector;
+
+ private final String associationPath;
+
/**
* Construct a ShardedSubcriteriaImpl
*
* @param shards the shards that we're aware of
* @param parent our parent
+ * @param criteriaCollector the collector for extit operations
+ * @param associationPath the association path for the subcriteria
*/
- public ShardedSubcriteriaImpl(List<Shard> shards, ShardedCriteria parent) {
+ public ShardedSubcriteriaImpl(List<Shard> shards, ShardedCriteria parent,
+ ExitOperationsCriteriaCollector criteriaCollector, String associationPath) {
Preconditions.checkNotNull(shards);
Preconditions.checkNotNull(parent);
Preconditions.checkArgument(!shards.isEmpty());
+ Preconditions.checkNotNull(criteriaCollector);
+ Preconditions.checkNotNull(associationPath);
this.shards = shards;
this.parent = parent;
+ this.criteriaCollector = criteriaCollector;
+ this.associationPath = associationPath;
// let's set up our maps
for(Shard shard : shards) {
shardToCriteriaMap.put(shard, null);
@@ -137,6 +148,7 @@
}
public Criteria addOrder(Order order) {
+ criteriaCollector.addOrder(associationPath, order);
CriteriaEvent event = new AddOrderEvent(order);
for (Shard shard : shards) {
if (shardToCriteriaMap.get(shard) != null) {
@@ -223,33 +235,13 @@
return this;
}
- /**
- * TODO(maxr)
- * This clearly isn't what people want. We should be building an
- * exit strategy that returns once we've accumulated maxResults
- * across _all_ shards, not each shard.
- */
public Criteria setMaxResults(int maxResults) {
- CriteriaEvent event = new SetMaxResultsEvent(maxResults);
- for (Shard shard : shards) {
- if (shardToCriteriaMap.get(shard) != null) {
- shardToCriteriaMap.get(shard).setMaxResults(maxResults);
- } else {
- shardToEventListMap.get(shard).add(event);
- }
- }
+ parent.setMaxResults(maxResults);
return this;
}
public Criteria setFirstResult(int firstResult) {
- CriteriaEvent event = new SetFirstResultEvent(firstResult);
- for (Shard shard : shards) {
- if (shardToCriteriaMap.get(shard) != null) {
- shardToCriteriaMap.get(shard).setFirstResult(firstResult);
- } else {
- shardToEventListMap.get(shard).add(event);
- }
- }
+ parent.setFirstResult(firstResult);
return this;
}
@@ -358,9 +350,12 @@
return getParentCriteria().uniqueResult();
}
- private ShardedSubcriteriaImpl createSubcriteria(SubcriteriaFactory factory) {
+ private ShardedSubcriteriaImpl createSubcriteria(SubcriteriaFactory factory,
+ String newAssociationPath) {
+ String fullAssociationPath = associationPath + "." + newAssociationPath;
// first build our sharded subcrit
- ShardedSubcriteriaImpl subcrit = new ShardedSubcriteriaImpl(shards, parent);
+ ShardedSubcriteriaImpl subcrit =
+ new ShardedSubcriteriaImpl(shards, parent, criteriaCollector, fullAssociationPath);
for (Shard shard : shards) {
// see if we already have a concreate Criteria object for each shard
if (shardToCriteriaMap.get(shard) != null) {
@@ -395,25 +390,25 @@
public Criteria createCriteria(String associationPath)
throws HibernateException {
SubcriteriaFactory factory = new SubcriteriaFactoryImpl(associationPath);
- return createSubcriteria(factory);
+ return createSubcriteria(factory, associationPath);
}
public Criteria createCriteria(String associationPath, int joinType)
throws HibernateException {
SubcriteriaFactory factory = new SubcriteriaFactoryImpl(associationPath, joinType);
- return createSubcriteria(factory);
+ return createSubcriteria(factory, associationPath);
}
public Criteria createCriteria(String associationPath, String alias)
throws HibernateException {
SubcriteriaFactory factory = new SubcriteriaFactoryImpl(associationPath, alias);
- return createSubcriteria(factory);
+ return createSubcriteria(factory, associationPath);
}
public Criteria createCriteria(String associationPath, String alias,
int joinType) throws HibernateException {
SubcriteriaFactory factory = new SubcriteriaFactoryImpl(associationPath, alias, joinType);
- return createSubcriteria(factory);
+ return createSubcriteria(factory, associationPath);
}
public ShardedCriteria getParentCriteria() {
Modified: shards/trunk/src/java/org/hibernate/shards/strategy/exit/ExitOperationUtils.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/strategy/exit/ExitOperationUtils.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/strategy/exit/ExitOperationUtils.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -50,7 +50,8 @@
public static Comparable<Object> getPropertyValue(Object obj, String propertyName) {
/**
* TODO(maulik) respect the client's choice in how Hibernate accesses
- * property values.
+ * property values. Also need to implement some caching - this gets called
+ * from a Comparator!
*
* Currently this method access members of an object using getters only,
* event of the client has specifed to use direct field access. Ideally,
Modified: shards/trunk/src/java/org/hibernate/shards/strategy/exit/OrderExitOperation.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/strategy/exit/OrderExitOperation.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/strategy/exit/OrderExitOperation.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -18,8 +18,8 @@
package org.hibernate.shards.strategy.exit;
-import org.hibernate.criterion.Order;
-import org.hibernate.shards.util.Preconditions;
+import org.hibernate.shards.criteria.InMemoryOrderBy;
+import org.hibernate.shards.util.Lists;
import java.util.Collections;
import java.util.Comparator;
@@ -30,50 +30,68 @@
*/
public class OrderExitOperation implements ExitOperation {
- private final Order order;
- private final String propertyName;
+ private final List<InMemoryOrderBy> orderByList;
- public OrderExitOperation(Order order) {
- //TODO(maulik) support Ignore case!
- Preconditions.checkState(order.toString().endsWith("asc") ||
- order.toString().endsWith("desc"));
+ private static final Comparator<Object> EQUALS = new Comparator<Object>() {
+ public int compare(Object o, Object o1) {
+ return 0;
+ }
+ };
- this.order = order;
- this.propertyName = getSortingProperty(order);
+ public OrderExitOperation(List<InMemoryOrderBy> orderByList) {
+ this.orderByList = Lists.newArrayList(orderByList);
+ // need to reverse the list so we build the comparator from the inside out
+ Collections.reverse(this.orderByList);
}
public List<Object> apply(List<Object> results) {
List<Object> nonNullList = ExitOperationUtils.getNonNullList(results);
- Comparator<Object> comparator = new Comparator<Object>() {
- public int compare(Object o1, Object o2) {
- if (o1 == o2) {
- return 0;
- }
- Comparable<Object> o1Value = ExitOperationUtils.getPropertyValue(o1, propertyName);
- Comparable<Object> o2Value = ExitOperationUtils.getPropertyValue(o2, propertyName);
- if (o1Value == null) {
- return -1;
- }
- return o1Value.compareTo(o2Value);
- }
- };
+ Comparator<Object> comparator = buildComparator();
Collections.sort(nonNullList, comparator);
- if (order.toString().endsWith("desc")) {
- Collections.reverse(nonNullList);
- }
return nonNullList;
}
- private static String getSortingProperty(Order order) {
- /**
- * This method relies on the format that Order is using:
- * propertyName + ' ' + (ascending?"asc":"desc")
- */
- String str = order.toString();
- return str.substring(0, str.indexOf(' '));
+ private Comparator<Object> buildComparator() {
+ // the most-inner comparator is one that returns 0 for everything.
+ Comparator<Object> inner = EQUALS;
+ for(InMemoryOrderBy order : orderByList) {
+ inner = new PropertyComparator(order.getExpression(), inner);
+ if(!order.isAscending()) {
+ inner = Collections.reverseOrder(inner);
+ }
+ }
+ return inner;
}
-
+ private static final class PropertyComparator implements Comparator<Object> {
+
+ private final String propertyName;
+ private final Comparator<Object> tieBreaker;
+
+ public PropertyComparator(String propertyName, Comparator<Object> tieBreaker) {
+ this.propertyName = propertyName;
+ this.tieBreaker = tieBreaker;
+ }
+
+ public int compare(Object o1, Object o2) {
+ int result;
+ if (o1 == o2) {
+ result = 0;
+ } else {
+ Comparable<Object> o1Value = ExitOperationUtils.getPropertyValue(o1, propertyName);
+ Comparable<Object> o2Value = ExitOperationUtils.getPropertyValue(o2, propertyName);
+ if (o1Value == null) {
+ result = -1;
+ } else {
+ result = o1Value.compareTo(o2Value);
+ }
+ }
+ if(result == 0) {
+ result = tieBreaker.compare(o1, o2);
+ }
+ return result;
+ }
+ }
}
Modified: shards/trunk/src/java/org/hibernate/shards/strategy/exit/RowCountExitOperation.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/strategy/exit/RowCountExitOperation.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/strategy/exit/RowCountExitOperation.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -36,7 +36,6 @@
public List<Object> apply(List<Object> results) {
List<Object> nonNullResults = ExitOperationUtils.getNonNullList(results);
-
return Collections.singletonList((Object) nonNullResults.size());
}
}
Modified: shards/trunk/src/java/org/hibernate/shards/strategy/selection/ShardResolutionStrategyDataImpl.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/strategy/selection/ShardResolutionStrategyDataImpl.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/java/org/hibernate/shards/strategy/selection/ShardResolutionStrategyDataImpl.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -44,4 +44,31 @@
return id;
}
+
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ ShardResolutionStrategyDataImpl that = (ShardResolutionStrategyDataImpl) o;
+
+ if (!entityName.equals(that.entityName)) {
+ return false;
+ }
+ if (!id.equals(that.id)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = entityName.hashCode();
+ result = 31 * result + id.hashCode();
+ return result;
+ }
}
Modified: shards/trunk/src/test/org/hibernate/shards/NonPermutedTests.java
===================================================================
--- shards/trunk/src/test/org/hibernate/shards/NonPermutedTests.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/test/org/hibernate/shards/NonPermutedTests.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -48,6 +48,7 @@
classes.add(org.hibernate.shards.criteria.CreateAliasEventTest.class);
classes.add(org.hibernate.shards.criteria.CreateSubcriteriaEventTest.class);
classes.add(org.hibernate.shards.criteria.CriteriaFactoryImplTest.class);
+ classes.add(org.hibernate.shards.criteria.InMemoryOrderByTest.class);
classes.add(org.hibernate.shards.criteria.SetCacheModeEventTest.class);
classes.add(org.hibernate.shards.criteria.SetCacheRegionEventTest.class);
classes.add(org.hibernate.shards.criteria.SetCacheableEventTest.class);
@@ -61,6 +62,7 @@
classes.add(org.hibernate.shards.criteria.SetProjectionEventTest.class);
classes.add(org.hibernate.shards.criteria.SetResultTransformerEventTest.class);
classes.add(org.hibernate.shards.criteria.SetTimeoutEventTest.class);
+ classes.add(org.hibernate.shards.criteria.ShardedCriteriaImplTest.class);
classes.add(org.hibernate.shards.criteria.ShardedSubcriteriaImplTest.class);
classes.add(org.hibernate.shards.criteria.SubcriteriaFactoryImplTest.class);
classes.add(org.hibernate.shards.id.ShardedTableHiLoGeneratorTest.class);
Added: shards/trunk/src/test/org/hibernate/shards/criteria/InMemoryOrderByTest.java
===================================================================
--- shards/trunk/src/test/org/hibernate/shards/criteria/InMemoryOrderByTest.java (rev 0)
+++ shards/trunk/src/test/org/hibernate/shards/criteria/InMemoryOrderByTest.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -0,0 +1,48 @@
+/**
+ * Copyright (C) 2007 Google Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package org.hibernate.shards.criteria;
+
+import junit.framework.TestCase;
+
+import org.hibernate.criterion.Order;
+
+/**
+ * @author maxr(a)google.com (Max Ross)
+ */
+public class InMemoryOrderByTest extends TestCase {
+
+ public void testTopLevel() {
+ InMemoryOrderBy imob = new InMemoryOrderBy(null, Order.asc("yam"));
+ assertEquals("yam", imob.getExpression());
+ assertTrue(imob.isAscending());
+
+ imob = new InMemoryOrderBy(null, Order.desc("yam"));
+ assertEquals("yam", imob.getExpression());
+ assertFalse(imob.isAscending());
+ }
+
+ public void testSubObject() {
+ InMemoryOrderBy imob = new InMemoryOrderBy("a.b.c", Order.asc("yam"));
+ assertEquals("a.b.c.yam", imob.getExpression());
+ assertTrue(imob.isAscending());
+
+ imob = new InMemoryOrderBy("a.b.c", Order.desc("yam"));
+ assertEquals("a.b.c.yam", imob.getExpression());
+ assertFalse(imob.isAscending());
+ }
+}
Added: shards/trunk/src/test/org/hibernate/shards/criteria/ShardedCriteriaImplTest.java
===================================================================
--- shards/trunk/src/test/org/hibernate/shards/criteria/ShardedCriteriaImplTest.java (rev 0)
+++ shards/trunk/src/test/org/hibernate/shards/criteria/ShardedCriteriaImplTest.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -0,0 +1,148 @@
+/**
+ * Copyright (C) 2008 Google Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package org.hibernate.shards.criteria;
+
+import junit.framework.TestCase;
+
+import org.hibernate.Criteria;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.shards.Shard;
+import org.hibernate.shards.ShardDefaultMock;
+import org.hibernate.shards.strategy.access.ShardAccessStrategy;
+import org.hibernate.shards.strategy.access.ShardAccessStrategyDefaultMock;
+import org.hibernate.shards.util.Lists;
+
+import java.util.List;
+
+/**
+ * @author maxr(a)google.com (Max Ross)
+ */
+public class ShardedCriteriaImplTest extends TestCase {
+
+ public void testSetFirstResultAfterMaxResult() {
+ CriteriaId id = new CriteriaId(0);
+ final List<CriteriaEvent> events = Lists.newArrayList();
+ Shard shard = new ShardDefaultMock() {
+ @Override
+ public SessionFactoryImplementor getSessionFactoryImplementor() {
+ return null;
+ }
+ @Override
+ public Criteria getCriteriaById(CriteriaId id) {
+ return null;
+ }
+ public void addCriteriaEvent(CriteriaId id, CriteriaEvent event) {
+ events.add(event);
+ }
+ };
+ List<Shard> shards = Lists.newArrayList(shard);
+ CriteriaFactory cf = new CriteriaFactoryDefaultMock();
+ ShardAccessStrategy sas = new ShardAccessStrategyDefaultMock();
+ ShardedCriteriaImpl crit = new ShardedCriteriaImpl(id, shards, cf, sas);
+ crit.setMaxResults(2);
+ assertEquals(2, crit.criteriaCollector.getMaxResults().intValue());
+ assertNull(crit.criteriaCollector.getFirstResult());
+ assertEquals(1, events.size());
+ assertEquals(2, ((SetMaxResultsEvent)events.get(0)).getMaxResults());
+
+ crit.setMaxResults(5);
+ assertEquals(5, crit.criteriaCollector.getMaxResults().intValue());
+ assertNull(crit.criteriaCollector.getFirstResult());
+ assertEquals(2, events.size());
+ assertEquals(2, ((SetMaxResultsEvent)events.get(0)).getMaxResults());
+ assertEquals(5, ((SetMaxResultsEvent)events.get(1)).getMaxResults());
+
+ crit.setFirstResult(2);
+ assertEquals(5, crit.criteriaCollector.getMaxResults().intValue());
+ assertEquals(2, crit.criteriaCollector.getFirstResult().intValue());
+ assertEquals(3, events.size());
+ assertEquals(2, ((SetMaxResultsEvent)events.get(0)).getMaxResults());
+ assertEquals(5, ((SetMaxResultsEvent)events.get(1)).getMaxResults());
+ assertEquals(7, ((SetMaxResultsEvent)events.get(2)).getMaxResults());
+
+ crit.setFirstResult(2);
+ assertEquals(5, crit.criteriaCollector.getMaxResults().intValue());
+ assertEquals(2, crit.criteriaCollector.getFirstResult().intValue());
+ assertEquals(4, events.size());
+ assertEquals(2, ((SetMaxResultsEvent)events.get(0)).getMaxResults());
+ assertEquals(5, ((SetMaxResultsEvent)events.get(1)).getMaxResults());
+ assertEquals(7, ((SetMaxResultsEvent)events.get(2)).getMaxResults());
+ assertEquals(7, ((SetMaxResultsEvent)events.get(3)).getMaxResults());
+
+ crit.setFirstResult(1);
+ assertEquals(5, crit.criteriaCollector.getMaxResults().intValue());
+ assertEquals(1, crit.criteriaCollector.getFirstResult().intValue());
+ assertEquals(5, events.size());
+ assertEquals(2, ((SetMaxResultsEvent)events.get(0)).getMaxResults());
+ assertEquals(5, ((SetMaxResultsEvent)events.get(1)).getMaxResults());
+ assertEquals(7, ((SetMaxResultsEvent)events.get(2)).getMaxResults());
+ assertEquals(7, ((SetMaxResultsEvent)events.get(3)).getMaxResults());
+ assertEquals(6, ((SetMaxResultsEvent)events.get(4)).getMaxResults());
+
+ crit.setFirstResult(0);
+ assertEquals(5, crit.criteriaCollector.getMaxResults().intValue());
+ assertEquals(0, crit.criteriaCollector.getFirstResult().intValue());
+ assertEquals(6, events.size());
+ assertEquals(2, ((SetMaxResultsEvent)events.get(0)).getMaxResults());
+ assertEquals(5, ((SetMaxResultsEvent)events.get(1)).getMaxResults());
+ assertEquals(7, ((SetMaxResultsEvent)events.get(2)).getMaxResults());
+ assertEquals(7, ((SetMaxResultsEvent)events.get(3)).getMaxResults());
+ assertEquals(6, ((SetMaxResultsEvent)events.get(4)).getMaxResults());
+ assertEquals(5, ((SetMaxResultsEvent)events.get(5)).getMaxResults());
+ }
+
+ public void testSetMaxResultAfterFirstResult() {
+ CriteriaId id = new CriteriaId(0);
+ final List<CriteriaEvent> events = Lists.newArrayList();
+ Shard shard = new ShardDefaultMock() {
+ @Override
+ public SessionFactoryImplementor getSessionFactoryImplementor() {
+ return null;
+ }
+ @Override
+ public Criteria getCriteriaById(CriteriaId id) {
+ return null;
+ }
+ public void addCriteriaEvent(CriteriaId id, CriteriaEvent event) {
+ events.add(event);
+ }
+ };
+ List<Shard> shards = Lists.newArrayList(shard);
+ CriteriaFactory cf = new CriteriaFactoryDefaultMock();
+ ShardAccessStrategy sas = new ShardAccessStrategyDefaultMock();
+ ShardedCriteriaImpl crit = new ShardedCriteriaImpl(id, shards, cf, sas);
+
+ crit.setFirstResult(3);
+ assertEquals(3, crit.criteriaCollector.getFirstResult().intValue());
+ assertNull(crit.criteriaCollector.getMaxResults());
+ assertEquals(0, events.size());
+
+ crit.setFirstResult(5);
+ assertEquals(5, crit.criteriaCollector.getFirstResult().intValue());
+ assertNull(crit.criteriaCollector.getMaxResults());
+ assertEquals(0, events.size());
+
+ crit.setMaxResults(2);
+ crit.setMaxResults(3);
+ assertEquals(5, crit.criteriaCollector.getFirstResult().intValue());
+ assertEquals(3, crit.criteriaCollector.getMaxResults().intValue());
+ assertEquals(2, events.size());
+ assertEquals(7, ((SetMaxResultsEvent)events.get(0)).getMaxResults());
+ assertEquals(8, ((SetMaxResultsEvent)events.get(1)).getMaxResults());
+ }
+}
Modified: shards/trunk/src/test/org/hibernate/shards/criteria/ShardedSubcriteriaImplTest.java
===================================================================
--- shards/trunk/src/test/org/hibernate/shards/criteria/ShardedSubcriteriaImplTest.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/test/org/hibernate/shards/criteria/ShardedSubcriteriaImplTest.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -19,6 +19,7 @@
package org.hibernate.shards.criteria;
import junit.framework.TestCase;
+
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.ScrollMode;
@@ -50,7 +51,10 @@
Shard s2 = new MyShard();
Shard s3 = new MyShard();
List<Shard> shards = Lists.newArrayList(s1, s2, s3);
- ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(shards, new ShardedCriteriaDefaultMock());
+ ExitOperationsCriteriaCollector collector =
+ new ExitOperationsCriteriaCollector();
+ ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(
+ shards, new ShardedCriteriaDefaultMock(), collector, "");
assertEquals(shards.size(), ss.getShardToCriteriaMap().size());
assertEquals(shards.size(), ss.getShardToEventListMap().size());
}
@@ -65,7 +69,10 @@
return null;
}
};
- ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(shards, parent);
+ ExitOperationsCriteriaCollector collector =
+ new ExitOperationsCriteriaCollector();
+ ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(
+ shards, parent, collector, "");
ss.list();
assertTrue(called[0]);
}
@@ -80,7 +87,10 @@
return null;
}
};
- ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(shards, parent);
+ ExitOperationsCriteriaCollector collector =
+ new ExitOperationsCriteriaCollector();
+ ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(
+ shards, parent, collector, "");
ss.uniqueResult();
assertTrue(called[0]);
}
@@ -103,7 +113,10 @@
return null;
}
};
- ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(shards, parent);
+ ExitOperationsCriteriaCollector collector =
+ new ExitOperationsCriteriaCollector();
+ ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(
+ shards, parent, collector, "");
ss.scroll();
assertTrue(scrollNoArgsCalled[0]);
assertFalse(scroll1ArgCalled[0]);
@@ -124,7 +137,10 @@
Shard someOtherShard = new ShardDefaultMock();
List<Shard> shards = Lists.newArrayList(shard, someOtherShard);
ShardedCriteria parent = new ShardedCriteriaDefaultMock();
- ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(shards, parent);
+ ExitOperationsCriteriaCollector collector =
+ new ExitOperationsCriteriaCollector();
+ ShardedSubcriteriaImpl ss = new ShardedSubcriteriaImpl(
+ shards, parent, collector, "");
ss.getShardToEventListMap().get(shard).add(new CriteriaEventDefaultMock());
final Criteria subcritToReturn = new CriteriaDefaultMock();
SubcriteriaFactory factory = new SubcriteriaFactoryDefaultMock() {
Modified: shards/trunk/src/test/org/hibernate/shards/integration/model/ModelCriteriaPermutedIntegrationTest.java
===================================================================
--- shards/trunk/src/test/org/hibernate/shards/integration/model/ModelCriteriaPermutedIntegrationTest.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/test/org/hibernate/shards/integration/model/ModelCriteriaPermutedIntegrationTest.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -229,10 +229,10 @@
Criteria officeCrit = floorCrit.createCriteria("offices");
officeCrit.add(Restrictions.eq("label", "LAHGE"));
// now how we execute the query via the floorcrit
- List<Integer> list = list(officeCrit);
- assertEquals(1, list.size());
+ List<Integer> result = list(officeCrit);
+ assertEquals(1, result.size());
int total = 0;
- for(int shardTotal : list) {
+ for(int shardTotal : result) {
total += shardTotal;
}
assertEquals(2, total);
@@ -240,17 +240,58 @@
public void testAvgProjection() {
Criteria crit = session.createCriteria(Floor.class).setProjection(Projections.avg("squareFeet"));
- List<Double> l = list(crit);
- assertEquals(1, l.size());
- assertEquals(20.0, l.get(0));
+ List<Double> result = list(crit);
+ assertEquals(1, result.size());
+ assertEquals(20.0, result.get(0));
}
-
public void testMaxResults() throws Exception {
Criteria crit = session.createCriteria(Building.class).setMaxResults(1);
assertEquals(1, list(crit).size());
}
+ public void testFirstAndMaxResults() {
+ Building b3 = ModelDataFactory.building("b3");
+ Building b4 = ModelDataFactory.building("b4");
+ Building b5 = ModelDataFactory.building("b5");
+ session.beginTransaction();
+ session.save(b5);
+ session.save(b3);
+ session.save(b4);
+ commitAndResetSession();
+
+ Criteria crit =
+ session.createCriteria(Building.class).addOrder(Order.desc("name")).
+ setFirstResult(2).setMaxResults(2);
+ List<Building> buildings = list(crit);
+ assertEquals(2, buildings.size());
+ assertEquals(b3, buildings.get(0));
+ assertEquals(b2, buildings.get(1));
+ }
+
+ public void testFirstAndMaxResultsWithSubCrit() {
+ Building b3 = ModelDataFactory.building("b3");
+ Floor b3f1 = ModelDataFactory.floor(b3, 1);
+ Building b4 = ModelDataFactory.building("b4");
+ Floor b4f1 = ModelDataFactory.floor(b4, 1);
+ Building b5 = ModelDataFactory.building("b5");
+ Floor b5f1 = ModelDataFactory.floor(b5, 1);
+ session.beginTransaction();
+ session.save(b5);
+ session.save(b3);
+ session.save(b4);
+ commitAndResetSession();
+
+ Criteria crit =
+ session.createCriteria(Building.class).addOrder(Order.desc("name")).
+ createCriteria("floors").add(Restrictions.eq("number", 1)).
+ setFirstResult(2).setMaxResults(2);
+ List<Building> buildings = list(crit);
+ assertEquals(2, buildings.size());
+ assertEquals(b3, buildings.get(0));
+ assertEquals(b2, buildings.get(1));
+ }
+
public void testAggregateProjection() throws Exception {
Criteria crit = session.createCriteria(Floor.class).setProjection(Projections.sum("number"));
List<Integer> l = list(crit);
@@ -276,10 +317,11 @@
public void testMultiOrdering() throws Exception {
Criteria crit = session.createCriteria(Office.class);
- crit.addOrder(Order.asc("label")).addOrder(Order.desc("floor.building.name"));
- List<Office> l = list(crit);
- List<Office> answer = Lists.newArrayList(b2f1o1, b1f3o1, b1f3o2);
- assertTrue(answer.equals(l));
+ crit.addOrder(Order.asc("label")).createCriteria("floor").
+ createCriteria("building").addOrder(Order.desc("name"));
+ List<Office> listResult = list(crit);
+ List<Office> answer = Lists.newArrayList(b2f1o1, b1f3o2, b1f3o1);
+ assertTrue(answer.equals(listResult));
}
}
Modified: shards/trunk/src/test/org/hibernate/shards/integration/platform/mysql/MySQLDatabasePlatform.java
===================================================================
--- shards/trunk/src/test/org/hibernate/shards/integration/platform/mysql/MySQLDatabasePlatform.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/test/org/hibernate/shards/integration/platform/mysql/MySQLDatabasePlatform.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -38,15 +38,15 @@
private static final Iterable<String> CREATE_TABLE_STATEMENTS = Lists.newArrayList(
"CREATE TABLE hibernate_unique_key (id DECIMAL(40,0) PRIMARY KEY, next_hi DECIMAL(40,0))"
- ,"INSERT INTO hibernate_unique_key(next_hi) VALUES(1)"
+ ,"INSERT INTO hibernate_unique_key(id, next_hi) VALUES(1,1)"
,"CREATE TABLE sample_table (id DECIMAL(40,0) PRIMARY KEY, str_col VARCHAR(256))"
,"CREATE TABLE sample_table2 (id DECIMAL(40,0) PRIMARY KEY, str_col VARCHAR(256))"
,"CREATE TABLE Elevator (elevatorId DECIMAL(40,0) PRIMARY KEY, buildingId DECIMAL(40,0))"
,"CREATE TABLE Building (buildingId DECIMAL(40,0) PRIMARY KEY, name VARCHAR(50))"
- ,"CREATE TABLE Floor (floorId DECIMAL(40,0) PRIMARY KEY, buildingId DECIMAL(40,0), upEscalatorId DECIMAL(40,0), downEscalatorId DECIMAL(40,0), number DECIMAL(40,0))"
+ ,"CREATE TABLE Floor (floorId DECIMAL(40,0) PRIMARY KEY, buildingId DECIMAL(40,0), upEscalatorId DECIMAL(40,0), downEscalatorId DECIMAL(40,0), number DECIMAL(40,0), squareFeet DECIMAL(40, 4))"
,"CREATE TABLE Tenant (tenantId DECIMAL(40,0) PRIMARY KEY, name VARCHAR(50))"
,"CREATE TABLE BuildingTenant (buildingId DECIMAL(40,0), tenantId DECIMAL(40,0), PRIMARY KEY(buildingId, tenantId))"
- ,"CREATE TABLE Office (officeId DECIMAL(40,0) PRIMARY KEY, floorId DECIMAL(40,0), label VARCHAR(50))"
+ ,"CREATE TABLE Office (officeId DECIMAL(40,0) PRIMARY KEY, floorId DECIMAL(40,0), label VARCHAR(50), windowId DECIMAL(40,0))"
,"CREATE TABLE FloorElevator (floorId DECIMAL(40,0), elevatorId DECIMAL(40,0), PRIMARY KEY(floorId, elevatorId))"
,"CREATE TABLE Escalator (escalatorId DECIMAL(40,0) PRIMARY KEY, bottomFloorId DECIMAL(40,0), topFloorId DECIMAL(40,0))"
,"CREATE TABLE Person (personId DECIMAL(40,0) PRIMARY KEY, name VARCHAR(50), tenantId DECIMAL(40,0), officeId DECIMAL(40,0))"
Modified: shards/trunk/src/test/org/hibernate/shards/model/Building.java
===================================================================
--- shards/trunk/src/test/org/hibernate/shards/model/Building.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/test/org/hibernate/shards/model/Building.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -108,4 +108,9 @@
public ShardId getShardId() {
return shardId;
}
+
+ @Override
+ public String toString() {
+ return buildingId.toString() + "," + name;
+ }
}
Modified: shards/trunk/src/test/org/hibernate/shards/strategy/exit/OrderExitOperationTest.java
===================================================================
--- shards/trunk/src/test/org/hibernate/shards/strategy/exit/OrderExitOperationTest.java 2008-02-13 04:27:52 UTC (rev 14332)
+++ shards/trunk/src/test/org/hibernate/shards/strategy/exit/OrderExitOperationTest.java 2008-02-13 20:41:47 UTC (rev 14333)
@@ -26,6 +26,7 @@
import org.hibernate.criterion.Order;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.shards.criteria.InMemoryOrderBy;
import org.hibernate.shards.defaultmock.ClassMetadataDefaultMock;
import org.hibernate.shards.defaultmock.EntityPersisterDefaultMock;
import org.hibernate.shards.defaultmock.SessionFactoryDefaultMock;
@@ -34,7 +35,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -43,30 +43,23 @@
*/
public class OrderExitOperationTest extends TestCase {
- private List<Object> data;
- private ArrayList<Object> shuffledList;
- private List<Object> nonNullData;
-
private class MyInt {
private final Integer i;
private final String name;
- private MyInt innerMyInt;
+ private final MyInt innerMyInt;
- public MyInt(int i, String name) {
+ public MyInt(int i, String name, MyInt inner) {
this.i = i;
this.name = name;
+ this.innerMyInt = inner;
}
public MyInt getInnerMyInt() {
return innerMyInt;
}
- public void setInnerMyInt(MyInt innerMyInt) {
- this.innerMyInt = innerMyInt;
- }
-
public Number getValue() {
return i;
}
@@ -83,53 +76,139 @@
}
}
- protected void setUp() throws Exception {
- super.setUp();
- String[] names = {"tomislav", "max", "maulik", "gut", "null", "bomb"};
- data = Lists.newArrayList();
- for(int i=0; i<6; i++) {
- if (i == 4) {
- data.add(null);
- } else {
- data.add(new MyInt(i, names[i]));
- }
- }
+ public void testApplySingleOrdering() throws Exception {
+ List<Object> data = Lists.newArrayList();
+ data.add(new MyInt(3, "tomislav", null));
+ data.add(new MyInt(1, "bomb", null));
+ data.add(new MyInt(27, "max", null));
+ data.add(new MyInt(2, "maulik", null));
+ data.add(new MyInt(5, "gut", null));
+
+ InMemoryOrderBy imob = new InMemoryOrderBy(null, Order.asc("value"));
+ OrderExitOperation oeo = new OrderExitOperation(Collections.singletonList(imob));
+ List<MyInt> sortedList = (List<MyInt>)(List)oeo.apply(data);
- nonNullData = ExitOperationUtils.getNonNullList(data);
+ assertEquals(1, sortedList.get(0).getValue());
+ assertEquals(2, sortedList.get(1).getValue());
+ assertEquals(3, sortedList.get(2).getValue());
+ assertEquals(5, sortedList.get(3).getValue());
+ assertEquals(27, sortedList.get(4).getValue());
- shuffledList = Lists.newArrayList(data);
- Collections.shuffle(shuffledList);
+ imob = new InMemoryOrderBy(null, Order.desc("value"));
+ oeo = new OrderExitOperation(Collections.singletonList(imob));
+ sortedList = (List<MyInt>)(List)oeo.apply(data);
+
+ assertEquals(27, sortedList.get(0).getValue());
+ assertEquals(5, sortedList.get(1).getValue());
+ assertEquals(3, sortedList.get(2).getValue());
+ assertEquals(2, sortedList.get(3).getValue());
+ assertEquals(1, sortedList.get(4).getValue());
}
- public void testApply() throws Exception {
- Order order = Order.asc("value");
- OrderExitOperation oeo = new OrderExitOperation(order);
- List unShuffledList = oeo.apply(shuffledList);
+ public void testApplySingleNestedOrdering() throws Exception {
+ List<Object> data = Lists.newArrayList();
+ data.add(new MyInt(3, "tomislav", new MyInt(3, "tomislav", null)));
+ data.add(new MyInt(1, "bomb", new MyInt(1, "bomb", null)));
+ data.add(new MyInt(27, "max", new MyInt(27, "max", null)));
+ data.add(new MyInt(2, "maulik", new MyInt(2, "maulik", null)));
+ data.add(new MyInt(5, "gut", new MyInt(5, "gut", null)));
- assertTrue(nonNullData.equals(unShuffledList));
+ InMemoryOrderBy imob = new InMemoryOrderBy(null, Order.asc("innerMyInt.value"));
+ OrderExitOperation oeo = new OrderExitOperation(Collections.singletonList(imob));
+ List<MyInt> sortedList = (List<MyInt>)(List)oeo.apply(data);
+
+ assertEquals(1, sortedList.get(0).getValue());
+ assertEquals(2, sortedList.get(1).getValue());
+ assertEquals(3, sortedList.get(2).getValue());
+ assertEquals(5, sortedList.get(3).getValue());
+ assertEquals(27, sortedList.get(4).getValue());
+
+ imob = new InMemoryOrderBy(null, Order.desc("innerMyInt.value"));
+ oeo = new OrderExitOperation(Collections.singletonList(imob));
+ sortedList = (List<MyInt>)(List)oeo.apply(data);
+
+ assertEquals(27, sortedList.get(0).getValue());
+ assertEquals(5, sortedList.get(1).getValue());
+ assertEquals(3, sortedList.get(2).getValue());
+ assertEquals(2, sortedList.get(3).getValue());
+ assertEquals(1, sortedList.get(4).getValue());
}
- public void testMultipleOrderings() throws Exception {
- Order orderValue = Order.asc("value");
- Order orderName = Order.desc("name");
+ public void testApplyMultipleOrderings() {
+ List<Object> data = Lists.newArrayList();
+ data.add(new MyInt(2, "tomislav", null));
+ data.add(new MyInt(1, "bomb", null));
+ data.add(new MyInt(27, "max", null));
+ data.add(new MyInt(2, "maulik", null));
+ data.add(new MyInt(5, "gut", null));
- OrderExitOperation oeoValue = new OrderExitOperation(orderValue);
- OrderExitOperation oeoName = new OrderExitOperation(orderName);
+ List<InMemoryOrderBy> list = Lists.newArrayList(
+ new InMemoryOrderBy(null, Order.asc("value")),
+ new InMemoryOrderBy(null, Order.desc("name"))
+ );
- List<MyInt> answer =
- Lists.newArrayList(
- new MyInt(0, "tomislav"),
- new MyInt(1, "max"),
- new MyInt(2, "maulik"),
- new MyInt(3, "gut"),
- new MyInt(5, "bomb"));
- List unShuffledList = oeoName.apply(oeoValue.apply(shuffledList));
+ OrderExitOperation operation = new OrderExitOperation(list);
+ List<MyInt> sortedList = (List<MyInt>)(List)operation.apply(data);
+ assertEquals(1, sortedList.get(0).getValue());
+ assertEquals(2, sortedList.get(1).getValue());
+ assertEquals("tomislav", sortedList.get(1).getName());
+ assertEquals(2, sortedList.get(2).getValue());
+ assertEquals("maulik", sortedList.get(2).getName());
+ assertEquals(5, sortedList.get(3).getValue());
+ assertEquals(27, sortedList.get(4).getValue());
+ }
- assertEquals(answer, unShuffledList);
+ public void testApplyMultipleNestedOrderings() {
+ List<Object> data = Lists.newArrayList();
+ data.add(new MyInt(2, "tomislav", new MyInt(2, "tomislav", null)));
+ data.add(new MyInt(1, "bomb", new MyInt(1, "bomb", null)));
+ data.add(new MyInt(27, "max", new MyInt(27, "max", null)));
+ data.add(new MyInt(2, "maulik", new MyInt(2, "maulik", null)));
+ data.add(new MyInt(5, "gut", new MyInt(5, "gut", null)));
+ List<InMemoryOrderBy> list = Lists.newArrayList(
+ new InMemoryOrderBy(null, Order.asc("innerMyInt.value")),
+ new InMemoryOrderBy(null, Order.desc("innerMyInt.name"))
+ );
+
+ OrderExitOperation operation = new OrderExitOperation(list);
+ List<MyInt> sortedList = (List<MyInt>)(List)operation.apply(data);
+
+ assertEquals(1, sortedList.get(0).getValue());
+ assertEquals(2, sortedList.get(1).getValue());
+ assertEquals("tomislav", sortedList.get(1).getName());
+ assertEquals(2, sortedList.get(2).getValue());
+ assertEquals("maulik", sortedList.get(2).getName());
+ assertEquals(5, sortedList.get(3).getValue());
+ assertEquals(27, sortedList.get(4).getValue());
}
+ public void testApplyMultipleMixedOrderings() {
+ List<Object> data = Lists.newArrayList();
+ data.add(new MyInt(2, "tomislav", new MyInt(2, "tomislav", null)));
+ data.add(new MyInt(1, "bomb", new MyInt(1, "bomb", null)));
+ data.add(new MyInt(27, "max", new MyInt(27, "max", null)));
+ data.add(new MyInt(2, "maulik", new MyInt(2, "maulik", null)));
+ data.add(new MyInt(5, "gut", new MyInt(5, "gut", null)));
+
+ List<InMemoryOrderBy> list = Lists.newArrayList(
+ new InMemoryOrderBy(null, Order.asc("innerMyInt.value")),
+ new InMemoryOrderBy(null, Order.desc("name"))
+ );
+
+ OrderExitOperation operation = new OrderExitOperation(list);
+ List<MyInt> sortedList = (List<MyInt>)(List)operation.apply(data);
+
+ assertEquals(1, sortedList.get(0).getValue());
+ assertEquals(2, sortedList.get(1).getValue());
+ assertEquals("tomislav", sortedList.get(1).getName());
+ assertEquals(2, sortedList.get(2).getValue());
+ assertEquals("maulik", sortedList.get(2).getName());
+ assertEquals(5, sortedList.get(3).getValue());
+ assertEquals(27, sortedList.get(4).getValue());
+ }
+
static class SessionFactoryMock extends SessionFactoryDefaultMock {
public ClassMetadata getClassMetadata(Class persistentClass)
16 years, 9 months