Hibernate SVN: r19272 - core/branches/Branch_3_5/parent.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-04-21 22:05:29 -0400 (Wed, 21 Apr 2010)
New Revision: 19272
Modified:
core/branches/Branch_3_5/parent/pom.xml
Log:
HHH-5144 Dont restrict on jdk5 in hibernate core development
Modified: core/branches/Branch_3_5/parent/pom.xml
===================================================================
--- core/branches/Branch_3_5/parent/pom.xml 2010-04-21 21:32:29 UTC (rev 19271)
+++ core/branches/Branch_3_5/parent/pom.xml 2010-04-22 02:05:29 UTC (rev 19272)
@@ -118,6 +118,28 @@
<extensions>true</extensions>
</plugin>
<plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>deploy</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source><![CDATA[
+ def javaVersion=System.getProperty("java.version")
+ if(!javaVersion.startsWith("1.5")){
+ fail("Please using JDK5 to do Hibernate release!")
+ }
+ ]]>
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
@@ -132,7 +154,7 @@
<rules>
<requireJavaVersion>
<!-- require JDK 1.5 to run the build -->
- <version>[1.5,1.6)</version>
+ <version>[1.5,)</version>
</requireJavaVersion>
<requireMavenVersion>
<!-- we need at least Maven 2.0.8 because of a bug fix affecting our antlr usage -->
14 years
Hibernate SVN: r19271 - validator/trunk.
by hibernate-commits@lists.jboss.org
Author: gunnar.morling
Date: 2010-04-21 17:32:29 -0400 (Wed, 21 Apr 2010)
New Revision: 19271
Modified:
validator/trunk/pom.xml
Log:
Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml 2010-04-21 17:17:21 UTC (rev 19270)
+++ validator/trunk/pom.xml 2010-04-21 21:32:29 UTC (rev 19271)
@@ -28,6 +28,13 @@
<organization>JBoss, a division of Red Hat</organization>
<url>http://in.relation.to/Bloggers/Hardy</url>
</developer>
+ <developer>
+ <id>gunnar.morling</id>
+ <name>Gunnar Morling</name>
+ <email>gunnar.morling(a)googlemail.com</email>
+ <organization>Individual</organization>
+ <url>http://musingsofaprogrammingaddict.blogspot.com/</url>
+ </developer>
</developers>
<mailingLists>
14 years
Hibernate SVN: r19270 - in search/trunk/hibernate-search/src: main/java/org/hibernate/search/query/dsl/v2/impl and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-04-21 13:17:21 -0400 (Wed, 21 Apr 2010)
New Revision: 19270
Added:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedMultiFieldsTermQueryBuilder.java
Removed:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedSingleTermQueryBuilder.java
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/TermContext.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/TermMatchingContext.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedTermContext.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedTermMatchingContext.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/FieldContext.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query/dsl/DSLTest.java
Log:
HSEARCH-508 Support query on multiple fields
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/TermContext.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/TermContext.java 2010-04-21 15:42:33 UTC (rev 19269)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/TermContext.java 2010-04-21 17:17:21 UTC (rev 19270)
@@ -11,4 +11,6 @@
*/
TermMatchingContext onField(String field);
+ TermMatchingContext onFields(String... field);
+
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/TermMatchingContext.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/TermMatchingContext.java 2010-04-21 15:42:33 UTC (rev 19269)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/TermMatchingContext.java 2010-04-21 17:17:21 UTC (rev 19270)
@@ -9,8 +9,8 @@
*/
TermTermination matches(String text);
-// /**
-// * field / property the term query is executed on
-// */
-// TermMatchingContext onField(String field);
+ /**
+ * field / property the term query is executed on
+ */
+ TermMatchingContext andField(String field);
}
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedMultiFieldsTermQueryBuilder.java (from rev 19264, search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedSingleTermQueryBuilder.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedMultiFieldsTermQueryBuilder.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedMultiFieldsTermQueryBuilder.java 2010-04-21 17:17:21 UTC (rev 19270)
@@ -0,0 +1,138 @@
+package org.hibernate.search.query.dsl.v2.impl;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.WildcardQuery;
+
+import org.hibernate.annotations.common.AssertionFailure;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.SearchFactory;
+import org.hibernate.search.query.dsl.v2.TermTermination;
+
+/**
+* @author Emmanuel Bernard
+*/
+public class ConnectedMultiFieldsTermQueryBuilder implements TermTermination {
+ private final String text;
+ private final Analyzer queryAnalyzer;
+ private final QueryCustomizer queryCustomizer;
+ private final QueryContext queryContext;
+ private final List<FieldContext> fieldContexts;
+
+ public ConnectedMultiFieldsTermQueryBuilder(QueryContext queryContext,
+ String text,
+ List<FieldContext> fieldContexts,
+ QueryCustomizer queryCustomizer,
+ Analyzer queryAnalyzer,
+ SearchFactory factory) {
+ this.queryContext = queryContext;
+ this.text = text;
+ this.queryAnalyzer = queryAnalyzer;
+ this.queryCustomizer = queryCustomizer;
+ this.fieldContexts = fieldContexts;
+ }
+
+ public Query createQuery() {
+ final int size = fieldContexts.size();
+ if ( size == 1 ) {
+ return queryCustomizer.setWrappedQuery( createQuery( fieldContexts.get( 0 ) ) ).createQuery();
+ }
+ else {
+ BooleanQuery aggregatedFieldsQuery = new BooleanQuery( );
+ for ( FieldContext fieldContext : fieldContexts ) {
+ aggregatedFieldsQuery.add( createQuery( fieldContext ), BooleanClause.Occur.SHOULD );
+ }
+ return queryCustomizer.setWrappedQuery( aggregatedFieldsQuery ).createQuery();
+ }
+ }
+
+ public Query createQuery(FieldContext fieldContext) {
+ final Query perFieldQuery;
+ if ( fieldContext.isIgnoreAnalyzer() ) {
+ perFieldQuery = createTermQuery( fieldContext, text );
+ }
+ else {
+ List<String> terms;
+ try {
+ terms = getAllTermsFromText( fieldContext.getField(), text, queryAnalyzer );
+ }
+ catch ( IOException e ) {
+ throw new AssertionFailure("IO exception while reading String stream??", e);
+ }
+ if ( terms.size() == 0 ) {
+ throw new SearchException( "try to search with an empty string: " + fieldContext.getField() );
+ }
+ else if (terms.size() == 1 ) {
+ perFieldQuery = createTermQuery( fieldContext, terms.get( 0 ) );
+ }
+ else {
+ BooleanQuery booleanQuery = new BooleanQuery();
+ for (String term : terms) {
+ Query termQuery = createTermQuery(fieldContext, term);
+ booleanQuery.add( termQuery, BooleanClause.Occur.SHOULD );
+ }
+ perFieldQuery = booleanQuery;
+ }
+ }
+ return fieldContext.getFieldCustomizer().setWrappedQuery( perFieldQuery ).createQuery();
+ }
+
+ private Query createTermQuery(FieldContext fieldContext, String term) {
+ Query query;
+ switch ( queryContext.getApproximation() ) {
+ case EXACT:
+ query = new TermQuery( new Term( fieldContext.getField(), term ) );
+ break;
+ case WILDCARD:
+ query = new WildcardQuery( new Term( fieldContext.getField(), term ) );
+ break;
+ case FUZZY:
+ query = new FuzzyQuery(
+ new Term( fieldContext.getField(), term ),
+ queryContext.getThreshold(),
+ queryContext.getPrefixLength() );
+ break;
+ default:
+ throw new AssertionFailure( "Unknown approximation: " + queryContext.getApproximation());
+ }
+ return query;
+ }
+
+ private List<String> getAllTermsFromText(String fieldName, String text, Analyzer analyzer) throws IOException {
+ //it's better not to apply the analyzer with windcards as * and ? can be mistakenly removed
+ List<String> terms = new ArrayList<String>();
+ if ( queryContext.getApproximation() == QueryContext.Approximation.WILDCARD ) {
+ terms.add( text );
+ }
+ else {
+ Reader reader = new StringReader(text);
+ TokenStream stream = analyzer.reusableTokenStream( fieldName, reader);
+ TermAttribute attribute = (TermAttribute) stream.addAttribute( TermAttribute.class );
+ stream.reset();
+
+ while ( stream.incrementToken() ) {
+ if ( attribute.termLength() > 0 ) {
+ String term = attribute.term();
+ terms.add( term );
+ }
+ }
+ stream.end();
+ stream.close();
+ }
+ return terms;
+ }
+
+}
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedSingleTermQueryBuilder.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedSingleTermQueryBuilder.java 2010-04-21 15:42:33 UTC (rev 19269)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedSingleTermQueryBuilder.java 2010-04-21 17:17:21 UTC (rev 19270)
@@ -1,127 +0,0 @@
-package org.hibernate.search.query.dsl.v2.impl;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.tokenattributes.TermAttribute;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.FuzzyQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.WildcardQuery;
-
-import org.hibernate.annotations.common.AssertionFailure;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.SearchFactory;
-import org.hibernate.search.query.dsl.v2.TermTermination;
-
-/**
-* @author Emmanuel Bernard
-*/
-public class ConnectedSingleTermQueryBuilder implements TermTermination {
- private final SearchFactory factory;
- private final String field;
- private final String text;
- private final Analyzer queryAnalyzer;
- private final QueryCustomizer queryCustomizer;
- private boolean ignoreAnalyzer;
- private final QueryContext context;
-
- public ConnectedSingleTermQueryBuilder(
- QueryContext context,
- boolean ignoreAnalyzer,
- String text,
- String field,
- QueryCustomizer queryCustomizer,
- Analyzer queryAnalyzer,
- SearchFactory factory) {
- this.context = context;
- this.factory = factory;
- this.field = field;
- this.text = text;
- this.queryAnalyzer = queryAnalyzer;
- this.queryCustomizer = queryCustomizer;
- this.ignoreAnalyzer = ignoreAnalyzer;
- }
-
- public Query createQuery() {
- final Query result;
- if ( ignoreAnalyzer ) {
- result = createTermQuery( text );
- }
- else {
- List<String> terms;
- try {
- terms = getAllTermsFromText( field, text, queryAnalyzer );
- }
- catch ( IOException e ) {
- throw new AssertionFailure("IO exception while reading String stream??", e);
- }
- if ( terms.size() == 0 ) {
- throw new SearchException("try to search with an empty string: " + field);
- }
- else if (terms.size() == 1 ) {
- result = createTermQuery( terms.get( 0 ) );
- }
- else {
- BooleanQuery booleanQuery = new BooleanQuery();
- for (String term : terms) {
- Query termQuery = createTermQuery(term);
- booleanQuery.add( termQuery, BooleanClause.Occur.SHOULD );
- }
- result = booleanQuery;
- }
- }
- return queryCustomizer.setWrappedQuery( result ).createQuery();
- }
-
- private Query createTermQuery(String term) {
- Query query;
- switch ( context.getApproximation() ) {
- case EXACT:
- query = new TermQuery( new Term(field, term) );
- break;
- case WILDCARD:
- query = new WildcardQuery( new Term(field, term) );
- break;
- case FUZZY:
- query = new FuzzyQuery( new Term(field, term), context.getThreshold(), context.getPrefixLength() );
- break;
- default:
- throw new AssertionFailure( "Unknown approximation: " + context.getApproximation());
- }
- return query;
- }
-
- private List<String> getAllTermsFromText(String fieldName, String text, Analyzer analyzer) throws IOException {
- //it's better not to apply the analyzer with windcards as * and ? can be mistakenly removed
- List<String> terms = new ArrayList<String>();
- if ( context.getApproximation() == QueryContext.Approximation.WILDCARD ) {
- terms.add( text );
- }
- else {
- Reader reader = new StringReader(text);
- TokenStream stream = analyzer.reusableTokenStream( fieldName, reader);
- TermAttribute attribute = (TermAttribute) stream.addAttribute( TermAttribute.class );
- stream.reset();
-
- while ( stream.incrementToken() ) {
- if ( attribute.termLength() > 0 ) {
- String term = attribute.term();
- terms.add( term );
- }
- }
- stream.end();
- stream.close();
- }
- return terms;
- }
-
-}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedTermContext.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedTermContext.java 2010-04-21 15:42:33 UTC (rev 19269)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedTermContext.java 2010-04-21 17:17:21 UTC (rev 19270)
@@ -27,6 +27,10 @@
return new ConnectedTermMatchingContext(context, field, queryCustomizer, queryAnalyzer, factory);
}
+ public TermMatchingContext onFields(String... fields) {
+ return new ConnectedTermMatchingContext(context, fields, queryCustomizer, queryAnalyzer, factory);
+ }
+
public TermContext boostedTo(float boost) {
queryCustomizer.boostedTo( boost );
return this;
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedTermMatchingContext.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedTermMatchingContext.java 2010-04-21 15:42:33 UTC (rev 19269)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/ConnectedTermMatchingContext.java 2010-04-21 17:17:21 UTC (rev 19270)
@@ -14,36 +14,61 @@
*/
public class ConnectedTermMatchingContext implements TermMatchingContext {
private final SearchFactory factory;
- private final String field;
private final Analyzer queryAnalyzer;
private final QueryCustomizer queryCustomizer;
- private boolean ignoreAnalyzer;
private final QueryContext queryContext;
- private final FieldContext fieldContext;
- private final List<ConnectedTermMatchingContext> otherFields;
+ private final List<FieldContext> fieldContexts;
+ //when a varargs of fields are passed, apply the same customization for all.
+ //keep the index of the first context in this queue
+ private int firstOfContext = 0;
public ConnectedTermMatchingContext(QueryContext queryContext,
String field, QueryCustomizer queryCustomizer, Analyzer queryAnalyzer, SearchFactory factory) {
this.factory = factory;
- this.field = field;
this.queryAnalyzer = queryAnalyzer;
this.queryCustomizer = queryCustomizer;
this.queryContext = queryContext;
- this.otherFields = new ArrayList<ConnectedTermMatchingContext>();
- this.fieldContext = null;
+ this.fieldContexts = new ArrayList<FieldContext>(4);
+ this.fieldContexts.add( new FieldContext( field ) );
}
+ public ConnectedTermMatchingContext(QueryContext queryContext,
+ String[] fields, QueryCustomizer queryCustomizer, Analyzer queryAnalyzer, SearchFactory factory) {
+ this.factory = factory;
+ this.queryAnalyzer = queryAnalyzer;
+ this.queryCustomizer = queryCustomizer;
+ this.queryContext = queryContext;
+ this.fieldContexts = new ArrayList<FieldContext>(fields.length);
+ for (String field : fields) {
+ this.fieldContexts.add( new FieldContext( field ) );
+ }
+ }
+
public TermTermination matches(String text) {
- return new ConnectedSingleTermQueryBuilder( queryContext, ignoreAnalyzer, text, field, queryCustomizer, queryAnalyzer, factory);
+ return new ConnectedMultiFieldsTermQueryBuilder( queryContext, text, fieldContexts, queryCustomizer, queryAnalyzer, factory);
}
+ public TermMatchingContext andField(String field) {
+ this.fieldContexts.add( new FieldContext( field ) );
+ this.firstOfContext = fieldContexts.size() - 1;
+ return this;
+ }
+
public TermMatchingContext boostedTo(float boost) {
- queryCustomizer.boostedTo( boost );
+ for ( FieldContext fieldContext : getCurrentFieldContexts() ) {
+ fieldContext.getFieldCustomizer().boostedTo( boost );
+ }
return this;
}
+ private List<FieldContext> getCurrentFieldContexts() {
+ return fieldContexts.subList( firstOfContext, fieldContexts.size() );
+ }
+
public TermMatchingContext ignoreAnalyzer() {
- this.ignoreAnalyzer = true;
+ for ( FieldContext fieldContext : getCurrentFieldContexts() ) {
+ fieldContext.setIgnoreAnalyzer( true );
+ }
return this;
}
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/FieldContext.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/FieldContext.java 2010-04-21 15:42:33 UTC (rev 19269)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/query/dsl/v2/impl/FieldContext.java 2010-04-21 17:17:21 UTC (rev 19270)
@@ -7,28 +7,18 @@
*/
public class FieldContext {
private final String field;
- private final Analyzer queryAnalyzer;
- private final QueryCustomizer queryCustomizer;
private boolean ignoreAnalyzer;
+ private final QueryCustomizer fieldCustomizer;
- public FieldContext(String field, Analyzer queryAnalyzer, QueryCustomizer queryCustomizer) {
+ public FieldContext(String field) {
this.field = field;
- this.queryAnalyzer = queryAnalyzer;
- this.queryCustomizer = queryCustomizer;
+ this.fieldCustomizer = new QueryCustomizer();
}
public String getField() {
return field;
}
- public Analyzer getQueryAnalyzer() {
- return queryAnalyzer;
- }
-
- public QueryCustomizer getQueryCustomizer() {
- return queryCustomizer;
- }
-
public boolean isIgnoreAnalyzer() {
return ignoreAnalyzer;
}
@@ -36,4 +26,8 @@
public void setIgnoreAnalyzer(boolean ignoreAnalyzer) {
this.ignoreAnalyzer = ignoreAnalyzer;
}
+
+ public QueryCustomizer getFieldCustomizer() {
+ return fieldCustomizer;
+ }
}
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query/dsl/DSLTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query/dsl/DSLTest.java 2010-04-21 15:42:33 UTC (rev 19269)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/query/dsl/DSLTest.java 2010-04-21 17:17:21 UTC (rev 19270)
@@ -14,7 +14,6 @@
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.search.Environment;
-import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.hibernate.search.annotations.Factory;
@@ -137,6 +136,54 @@
cleanData( fts );
}
+ public void testMultipleFields() throws Exception {
+ FullTextSession fts = initData();
+
+ Transaction transaction = fts.beginTransaction();
+ final QueryBuilder monthQb = fts.getSearchFactory()
+ .buildQueryBuilder().forEntity( Month.class ).get();
+ Query
+
+ //combined query, January and february both contain whitening but February in a longer text
+ query = monthQb.exact()
+ .onField( "mythology" )
+ .andField( "history" )
+ .matches( "whitening" ).createQuery();
+
+ List<Month> results = fts.createFullTextQuery( query, Month.class ).list();
+ assertEquals( 2, results.size() );
+ assertEquals( "January", results.get( 0 ).getName() );
+
+ //combined query, January and february both contain whitening but February in a longer text
+ query = monthQb.exact()
+ .onFields( "mythology", "history" )
+ .boostedTo( 30 )
+ .matches( "whitening" ).createQuery();
+
+ results = fts.createFullTextQuery( query, Month.class ).list();
+ assertEquals( 2, results.size() );
+ assertEquals( "January", results.get( 0 ).getName() );
+
+ //boosted query, January and february both contain whitening but February in a longer text
+ //since history is boosted, February should come first though
+ query = monthQb.exact()
+ .onField( "mythology" )
+ .andField( "history" )
+ .boostedTo( 30 )
+ .matches( "whitening" )
+ .createQuery();
+
+ results = fts.createFullTextQuery( query, Month.class ).list();
+ assertEquals( 2, results.size() );
+ assertEquals( "February", results.get( 0 ).getName() );
+
+ //FIXME add other method tests besides boostedTo
+
+ transaction.commit();
+
+ cleanData( fts );
+ }
+
public void testBoolean() throws Exception {
FullTextSession fts = initData();
14 years
Hibernate SVN: r19269 - annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/cid.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-04-21 11:42:33 -0400 (Wed, 21 Apr 2010)
New Revision: 19269
Modified:
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/cid/CompositeIdTest.java
Log:
JBPAPP-3223 HHH-3164 'id in ...' with EmbeddedId and criteria API
Modified: annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/cid/CompositeIdTest.java
===================================================================
--- annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/cid/CompositeIdTest.java 2010-04-21 13:57:59 UTC (rev 19268)
+++ annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/cid/CompositeIdTest.java 2010-04-21 15:42:33 UTC (rev 19269)
@@ -264,10 +264,7 @@
}
public void testQueryInAndComposite() {
- //HHH-4907
- if(!Dialect.getDialect().supportsRowValueConstructorSyntaxInInList()){
- return;
- }
+
Session s = openSession( );
Transaction transaction = s.beginTransaction();
@@ -303,19 +300,22 @@
s.persist( someEntity );
s.flush();
+ //HHH-4907
+ if ( Dialect.getDialect().supportsRowValueConstructorSyntaxInInList() ) {
- List ids = new ArrayList<SomeEntityId>(2);
- ids.add( new SomeEntityId(1,12) );
- ids.add( new SomeEntityId(10,23) );
+ List ids = new ArrayList<SomeEntityId>( 2 );
+ ids.add( new SomeEntityId( 1, 12 ) );
+ ids.add( new SomeEntityId( 10, 23 ) );
- Criteria criteria = s.createCriteria( SomeEntity.class );
- Disjunction disjunction = Restrictions.disjunction();
+ Criteria criteria = s.createCriteria( SomeEntity.class );
+ Disjunction disjunction = Restrictions.disjunction();
- disjunction.add( Restrictions.in( "id", ids ) );
- criteria.add( disjunction );
+ disjunction.add( Restrictions.in( "id", ids ) );
+ criteria.add( disjunction );
- List list = criteria.list();
- assertEquals( 2, list.size() );
+ List list = criteria.list();
+ assertEquals( 2, list.size() );
+ }
transaction.rollback();
s.close();
}
14 years
Hibernate SVN: r19268 - search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-04-21 09:57:59 -0400 (Wed, 21 Apr 2010)
New Revision: 19268
Modified:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForDoc0.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForUnindexed.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForDoc0.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForUnindexed.java
Log:
HSEARCH-504 Fix ContainedIn tests which break on Oracle as they use a reserved keyword as column name
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForDoc0.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForDoc0.java 2010-04-21 13:37:39 UTC (rev 19267)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForDoc0.java 2010-04-21 13:57:59 UTC (rev 19268)
@@ -25,6 +25,7 @@
@Id
@GeneratedValue //(generator = "ids_generator1", strategy = GenerationType.SEQUENCE)
+ @Column(name="universalid")//"uid" is a keywork in Oracle
private long uid;
@Version
@@ -34,7 +35,7 @@
@org.hibernate.search.annotations.IndexedEmbedded
private java.util.List<Entity2ForDoc0> entities2 = new java.util.ArrayList<Entity2ForDoc0>();
- @Column(name="universalid")//"uid" is a keywork in Oracle
+
public long getUid() {
return uid;
}
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForUnindexed.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForUnindexed.java 2010-04-21 13:37:39 UTC (rev 19267)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity1ForUnindexed.java 2010-04-21 13:57:59 UTC (rev 19268)
@@ -26,6 +26,7 @@
@Id
@GeneratedValue
@Field(index = Index.UN_TOKENIZED)
+ @Column(name="universalid")
private long uid;
@Version
@@ -36,7 +37,7 @@
@org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
private java.util.List<Entity2ForUnindexed> entities2 = new java.util.ArrayList<Entity2ForUnindexed>();
- @Column(name="universalid")
+
public long getUid() {
return uid;
}
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForDoc0.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForDoc0.java 2010-04-21 13:37:39 UTC (rev 19267)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForDoc0.java 2010-04-21 13:57:59 UTC (rev 19268)
@@ -18,6 +18,7 @@
@Id
@GeneratedValue //(generator = "ids_generator2", strategy = GenerationType.SEQUENCE)
+ @Column(name="universalid")//"uid" is a keywork in Oracle
private long uid;
@Version
@@ -38,7 +39,7 @@
this.name = name;
}
- @Column(name="universalid")//"uid" is a keywork in Oracle
+
public long getUid() {
return uid;
}
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForUnindexed.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForUnindexed.java 2010-04-21 13:37:39 UTC (rev 19267)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/embedded/nested/containedIn/Entity2ForUnindexed.java 2010-04-21 13:57:59 UTC (rev 19268)
@@ -26,6 +26,7 @@
*/
@Id
@GeneratedValue
+ @Column(name="universalid")//"uid" is a keywork in Oracle
private long uid;
/**
@@ -44,7 +45,7 @@
*
* @return long : Renvoie uid.
*/
- @Column(name="universalid")//"uid" is a keywork in Oracle
+
public long getUid() {
return uid;
}
14 years
Hibernate SVN: r19267 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-04-21 09:37:39 -0400 (Wed, 21 Apr 2010)
New Revision: 19267
Added:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java
Log:
HHH-4968 Do not activate Bean Validation listeners when only DDL is requested (Vladimir Klyushnikov).
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java 2010-04-21 13:26:17 UTC (rev 19266)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/BeanValidationDisabledTest.java 2010-04-21 13:37:39 UTC (rev 19267)
@@ -3,8 +3,10 @@
import java.math.BigDecimal;
import javax.validation.ConstraintViolationException;
+import org.hibernate.mapping.PersistentClass;
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.mapping.Column;
import org.hibernate.cfg.Configuration;
import org.hibernate.test.annotations.TestCase;
@@ -27,6 +29,12 @@
tx.rollback();
s.close();
}
+
+ public void testDDLDisabled() {
+ PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
+ Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
+ assertTrue("DDL constraints are applied", countryColumn.isNullable() );
+ }
@Override
protected void configure(Configuration cfg) {
@@ -36,7 +44,8 @@
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
+ Address.class,
CupHolder.class
};
}
-}
\ No newline at end of file
+}
Added: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java (rev 0)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/beanvalidation/DDLWithoutCallbackTest.java 2010-04-21 13:37:39 UTC (rev 19267)
@@ -0,0 +1,51 @@
+package org.hibernate.test.annotations.beanvalidation;
+
+import java.math.BigDecimal;
+import javax.validation.ConstraintViolationException;
+
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.mapping.Column;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.test.annotations.TestCase;
+
+/**
+ * @author Vladimir Klyushnikov
+ */
+public class DDLWithoutCallbackTest extends TestCase {
+ public void testListeners() {
+ CupHolder ch = new CupHolder();
+ ch.setRadius( new BigDecimal( "12" ) );
+ Session s = openSession( );
+ Transaction tx = s.beginTransaction();
+ try {
+ s.persist( ch );
+ s.flush();
+ }
+ catch ( ConstraintViolationException e ) {
+ fail("invalid object should not be validated");
+ }
+ tx.rollback();
+ s.close();
+ }
+
+ public void testDDLEnabled() {
+ PersistentClass classMapping = getCfg().getClassMapping( Address.class.getName() );
+ Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
+ assertFalse("DDL constraints are not applied", countryColumn.isNullable() );
+ }
+
+ @Override
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( "javax.persistence.validation.mode", "ddl" );
+ }
+
+ protected Class<?>[] getAnnotatedClasses() {
+ return new Class<?>[] {
+ Address.class,
+ CupHolder.class
+ };
+ }
+}
14 years
Hibernate SVN: r19266 - core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-04-21 09:26:17 -0400 (Wed, 21 Apr 2010)
New Revision: 19266
Modified:
core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationActivator.java
Log:
HHH-4968 do not activate Bean Validation listeners when only DDL is requested.
Modified: core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationActivator.java
===================================================================
--- core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationActivator.java 2010-04-21 13:11:29 UTC (rev 19265)
+++ core/trunk/annotations/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationActivator.java 2010-04-21 13:26:17 UTC (rev 19266)
@@ -50,7 +50,7 @@
properties.setProperty( Environment.CHECK_NULLABILITY, "false" );
}
- if ( modes.contains( ValidationMode.NONE ) ) return;
+ if ( ! ( modes.contains( ValidationMode.CALLBACK ) || modes.contains( ValidationMode.AUTO ) ) ) return;
try {
Class<?> activator = ReflectHelper.classForName( TYPE_SAFE_ACTIVATOR_CLASS, BeanValidationActivator.class );
14 years
Hibernate SVN: r19265 - core/trunk/parent.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-04-21 09:11:29 -0400 (Wed, 21 Apr 2010)
New Revision: 19265
Modified:
core/trunk/parent/pom.xml
Log:
HHH-5139 - Increase minimum language level from 1.4 to 1.5
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2010-04-21 09:40:24 UTC (rev 19264)
+++ core/trunk/parent/pom.xml 2010-04-21 13:11:29 UTC (rev 19265)
@@ -142,13 +142,13 @@
</rules>
</configuration>
</plugin>
- <!-- by default, compile to JDK 1.4 compatibility (individual modules and/or user can override) -->
+ <!-- by default, compile to JDK 1.5 compatibility (individual modules and/or user can override) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.4</source>
- <target>1.4</target>
+ <source>1.5</source>
+ <target>1.5</target>
</configuration>
</plugin>
<!-- add specification/implementation details to the manifests -->
14 years
Hibernate SVN: r19264 - commons-annotations/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-04-21 05:40:24 -0400 (Wed, 21 Apr 2010)
New Revision: 19264
Modified:
commons-annotations/trunk/pom.xml
Log:
HCANN-20
Modified: commons-annotations/trunk/pom.xml
===================================================================
--- commons-annotations/trunk/pom.xml 2010-04-21 09:25:37 UTC (rev 19263)
+++ commons-annotations/trunk/pom.xml 2010-04-21 09:40:24 UTC (rev 19264)
@@ -130,16 +130,14 @@
<distributionManagement>
<repository>
- <!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
- <!-- It is anticipated that ${maven.repository.root} be set in user's settings.xml -->
- <!-- todo : replace this with direct svn access once the svnkit providers are available -->
- <id>repository.jboss.org</id>
- <url>file://${maven.repository.root}</url>
+ <id>jboss-releases-repository</id>
+ <name>JBoss Releases Repository</name>
+ <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshot Repository</name>
- <url>dav:https://snapshots.jboss.org/maven2</url>
+ <id>jboss-snapshots-repository</id>
+ <name>JBoss Snapshots Repository</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
14 years
Hibernate SVN: r19263 - beanvalidation/api/trunk.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-04-21 05:25:37 -0400 (Wed, 21 Apr 2010)
New Revision: 19263
Modified:
beanvalidation/api/trunk/pom.xml
Log:
BVAL-206
Modified: beanvalidation/api/trunk/pom.xml
===================================================================
--- beanvalidation/api/trunk/pom.xml 2010-04-21 09:11:58 UTC (rev 19262)
+++ beanvalidation/api/trunk/pom.xml 2010-04-21 09:25:37 UTC (rev 19263)
@@ -94,16 +94,14 @@
<distributionManagement>
<repository>
- <!-- Copy the dist to the local checkout of the JBoss maven2 repo ${maven.repository.root} -->
- <!-- It is anticipated that ${maven.repository.root} be set in user's settings.xml -->
- <!-- todo : replace this with direct svn access once the svnkit providers are available -->
- <id>repository.jboss.org</id>
- <url>file://${maven.repository.root}</url>
+ <id>jboss-releases-repository</id>
+ <name>JBoss Releases Repository</name>
+ <url>https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/</url>
</repository>
<snapshotRepository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshot Repository</name>
- <url>dav:https://snapshots.jboss.org/maven2</url>
+ <id>jboss-snapshots-repository</id>
+ <name>JBoss Snapshots Repository</name>
+ <url>https://repository.jboss.org/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
14 years