Hibernate SVN: r21061 - annotations/patches.
by hibernate-commits@lists.jboss.org
Author: brmeyer
Date: 2012-08-30 12:47:48 -0400 (Thu, 30 Aug 2012)
New Revision: 21061
Added:
annotations/patches/JBPAPP-6940/
Log:
Branching for JBPAPP-6940
12 years, 7 months
Hibernate SVN: r21060 - annotations/patches/JBPAPP-7103/src/main/java/org/hibernate/cfg/annotations and 10 other directories.
by hibernate-commits@lists.jboss.org
Author: brmeyer
Date: 2012-08-30 12:43:27 -0400 (Thu, 30 Aug 2012)
New Revision: 21060
Added:
core/patches/JBPAPP-7103/core/src/main/antlr/order-by-render.g
core/patches/JBPAPP-7103/core/src/main/antlr/order-by.g
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/CollationSpecification.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/ColumnMapper.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/ColumnReference.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/Factory.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/FormulaReference.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/Node.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/NodeSupport.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByAliasResolver.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragment.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentRenderer.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentTranslator.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByTranslation.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderingSpecification.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SortKey.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SortSpecification.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SqlValueReference.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/TranslationContext.java
Modified:
annotations/patches/JBPAPP-7103/
annotations/patches/JBPAPP-7103/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
annotations/patches/JBPAPP-7103/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
annotations/patches/JBPAPP-7103/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java
core/patches/JBPAPP-7103/
core/patches/JBPAPP-7103/core/pom.xml
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/Loadable.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/Queryable.java
core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/Template.java
Log:
JBPAPP-7103 @OrderBy usage on a joined classes (when using join table) produces incorred SQL syntax
Property changes on: annotations/patches/JBPAPP-7103
___________________________________________________________________
Added: svn:ignore
+ .settings
target
.classpath
.project
Modified: annotations/patches/JBPAPP-7103/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- annotations/patches/JBPAPP-7103/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ annotations/patches/JBPAPP-7103/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -1,12 +1,9 @@
package org.hibernate.cfg.annotations;
-import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
-import java.util.StringTokenizer;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
@@ -77,9 +74,7 @@
import org.hibernate.mapping.ManyToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
-import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.mapping.Table;
import org.hibernate.util.StringHelper;
import org.slf4j.Logger;
@@ -818,188 +813,33 @@
}
}
- private static String buildOrderByClauseFromHql(String hqlOrderBy, PersistentClass associatedClass, String role) {
- String orderByString = null;
- if ( hqlOrderBy != null ) {
- List<String> properties = new ArrayList<String>();
- List<String> ordering = new ArrayList<String>();
- StringBuilder orderByBuffer = new StringBuilder();
- if ( hqlOrderBy.length() == 0 ) {
+ private static String buildOrderByClauseFromHql(String orderByFragment, PersistentClass associatedClass, String role) {
+ if ( orderByFragment != null ) {
+ if ( orderByFragment.length() == 0 ) {
//order by id
- Iterator it = associatedClass.getIdentifier().getColumnIterator();
- while ( it.hasNext() ) {
- Selectable col = (Selectable) it.next();
- orderByBuffer.append( col.getText() ).append( " asc" ).append( ", " );
- }
+ return "id asc";
}
- else {
- StringTokenizer st = new StringTokenizer( hqlOrderBy, " ,", false );
- String currentOrdering = null;
- //FIXME make this code decent
- while ( st.hasMoreTokens() ) {
- String token = st.nextToken();
- if ( isNonPropertyToken( token ) ) {
- if ( currentOrdering != null ) {
- throw new AnnotationException(
- "Error while parsing HQL orderBy clause: " + hqlOrderBy
- + " (" + role + ")"
- );
- }
- currentOrdering = token;
- }
- else {
- //Add ordering of the previous
- if ( currentOrdering == null ) {
- //default ordering
- ordering.add( "asc" );
- }
- else {
- ordering.add( currentOrdering );
- currentOrdering = null;
- }
- properties.add( token );
- }
- }
- ordering.remove( 0 ); //first one is the algorithm starter
- // add last one ordering
- if ( currentOrdering == null ) {
- //default ordering
- ordering.add( "asc" );
- }
- else {
- ordering.add( currentOrdering );
- currentOrdering = null;
- }
- int index = 0;
-
- for (String property : properties) {
- Property p = BinderHelper.findPropertyByName( associatedClass, property );
- if ( p == null ) {
- throw new AnnotationException(
- "property from @OrderBy clause not found: "
- + associatedClass.getEntityName() + "." + property
- );
- }
- PersistentClass pc = p.getPersistentClass();
- String table;
- if ( pc == null ) {
- //we are touching a @IdClass property, the pc is not set
- //this means pc == associatedClass
- //TODO check whether @ManyToOne @JoinTable in @IdClass used for @OrderBy works: doh!
- table = "";
- }
-
- else if (pc == associatedClass
- || (associatedClass instanceof SingleTableSubclass && pc
- .getMappedClass().isAssignableFrom(
- associatedClass.getMappedClass()))) {
- table = "";
- } else {
- table = pc.getTable().getQuotedName() + ".";
- }
-
- Iterator propertyColumns = p.getColumnIterator();
- while ( propertyColumns.hasNext() ) {
- Selectable column = (Selectable) propertyColumns.next();
- orderByBuffer.append( table )
- .append( column.getText() )
- .append( " " )
- .append( ordering.get( index ) )
- .append( ", " );
- }
- index++;
- }
+ else if ( "desc".equals( orderByFragment ) ) {
+ return "id desc";
}
- orderByString = orderByBuffer.substring( 0, orderByBuffer.length() - 2 );
}
- return orderByString;
+ return orderByFragment;
}
- private static String buildOrderByClauseFromHql(String hqlOrderBy, Component component, String role) {
- String orderByString = null;
- if ( hqlOrderBy != null ) {
- List<String> properties = new ArrayList<String>();
- List<String> ordering = new ArrayList<String>();
- StringBuilder orderByBuffer = new StringBuilder();
- if ( hqlOrderBy.length() == 0 ) {
- //TODO : Check that. Maybe order by key for maps
+ private static String adjustUserSuppliedValueCollectionOrderingFragment(String orderByFragment) {
+ if ( orderByFragment != null ) {
+ // NOTE: "$element$" is a specially recognized collection property recognized by the collection persister
+ if ( orderByFragment.length() == 0 ) {
+ //order by element
+ return "$element$ asc";
}
- else {
- StringTokenizer st = new StringTokenizer( hqlOrderBy, " ,", false );
- String currentOrdering = null;
- //FIXME make this code decent
- while ( st.hasMoreTokens() ) {
- String token = st.nextToken();
- if ( isNonPropertyToken( token ) ) {
- if ( currentOrdering != null ) {
- throw new AnnotationException(
- "Error while parsing HQL orderBy clause: " + hqlOrderBy
- + " (" + role + ")"
- );
- }
- currentOrdering = token;
- }
- else {
- //Add ordering of the previous
- if ( currentOrdering == null ) {
- //default ordering
- ordering.add( "asc" );
- }
- else {
- ordering.add( currentOrdering );
- currentOrdering = null;
- }
- properties.add( token );
- }
- }
- ordering.remove( 0 ); //first one is the algorithm starter
- // add last one ordering
- if ( currentOrdering == null ) {
- //default ordering
- ordering.add( "asc" );
- }
- else {
- ordering.add( currentOrdering );
- currentOrdering = null;
- }
- int index = 0;
-
- for (String property : properties) {
- Property p = component.getProperty( property );
- if ( p == null ) {
- throw new AnnotationException(
- "property from @OrderBy clause not found: "
- + role + "." + property
- );
- }
-
- Iterator propertyColumns = p.getColumnIterator();
- while ( propertyColumns.hasNext() ) {
- Selectable column = (Selectable) propertyColumns.next();
- orderByBuffer.append( column.getText() )
- .append( " " )
- .append( ordering.get( index ) )
- .append( ", " );
- }
- index++;
- }
-
- if ( orderByBuffer.length() >= 2 ) {
- orderByString = orderByBuffer.substring( 0, orderByBuffer.length() - 2 );
- }
+ else if ( "desc".equals( orderByFragment ) ) {
+ return "$element$ desc";
}
}
- return orderByString;
+ return orderByFragment;
}
- private static boolean isNonPropertyToken(String token) {
- if ( " ".equals( token ) ) return true;
- if ( ",".equals( token ) ) return true;
- if ( token.equalsIgnoreCase( "desc" ) ) return true;
- if ( token.equalsIgnoreCase( "asc" ) ) return true;
- return false;
- }
-
private static SimpleValue buildCollectionKey(
Collection collValue, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled,
XProperty property, ExtendedMappings mappings
@@ -1267,8 +1107,7 @@
collValue.setElement( component );
if ( StringHelper.isNotEmpty( hqlOrderBy ) ) {
- String path = collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName();
- String orderBy = buildOrderByClauseFromHql( hqlOrderBy, component, path );
+ String orderBy = adjustUserSuppliedValueCollectionOrderingFragment( hqlOrderBy );
if ( orderBy != null ) {
collValue.setOrderBy( orderBy );
}
@@ -1299,6 +1138,10 @@
elementBinder.setColumns( elementColumns );
elementBinder.setType( property, elementClass );
collValue.setElement( elementBinder.make() );
+ String orderBy = adjustUserSuppliedValueCollectionOrderingFragment( hqlOrderBy );
+ if ( orderBy != null ) {
+ collValue.setOrderBy( orderBy );
+ }
}
}
Modified: annotations/patches/JBPAPP-7103/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java
===================================================================
--- annotations/patches/JBPAPP-7103/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ annotations/patches/JBPAPP-7103/src/test/java/org/hibernate/test/annotations/manytomany/ManyToManyTest.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -7,6 +7,7 @@
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.hibernate.Hibernate;
@@ -256,6 +257,53 @@
}
+ // HHH-4394
+ public void testOrderByContractor() throws Exception {
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+
+ // create some test entities
+ Employer employer = new Employer();
+ Contractor contractor1 = new Contractor();
+ contractor1.setName( "Emmanuel" );
+ contractor1.setHourlyRate(100.0f);
+ Contractor contractor2 = new Contractor();
+ contractor2.setName( "Hardy" );
+ contractor2.setHourlyRate(99.99f);
+ s.persist( contractor1 );
+ s.persist( contractor2 );
+
+ // add contractors to employer
+ List setOfContractors = new ArrayList();
+ setOfContractors.add( contractor1 );
+ setOfContractors.add( contractor2 );
+ employer.setContractors( setOfContractors );
+
+ // add employer to contractors
+ Collection employerListContractor1 = new ArrayList();
+ employerListContractor1.add( employer );
+ contractor1.setEmployers( employerListContractor1 );
+
+ Collection employerListContractor2 = new ArrayList();
+ employerListContractor2.add( employer );
+ contractor2.setEmployers( employerListContractor2 );
+
+ s.flush();
+ s.clear();
+
+ // assertions
+ employer = (Employer) s.get( Employer.class, employer.getId() );
+ assertNotNull( employer );
+ assertNotNull( employer.getContractors() );
+ assertEquals( 2, employer.getContractors().size() );
+ Contractor firstContractorFromDb = (Contractor) employer.getContractors().iterator().next();
+ assertEquals( contractor2.getName(), firstContractorFromDb.getName() );
+ tx.rollback();
+ s.close();
+ }
+
/**
* ANN-625
*
Modified: annotations/patches/JBPAPP-7103/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java
===================================================================
--- annotations/patches/JBPAPP-7103/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ annotations/patches/JBPAPP-7103/src/test/java/org/hibernate/test/annotations/onetomany/OneToManyTest.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -78,10 +78,16 @@
s.flush();
s.clear();
- //testing @OrderBy with explicit values including Formula
+ // Assert the primary key value relationship amongst the 3 streets...
+ assertTrue( rochechoir.getId() < chmpsElysees.getId() );
+ assertTrue( chmpsElysees.getId() < grandeArmee.getId() );
paris = (City) s.get( City.class, paris.getId() );
+
+ // City.streets is defined to be ordered by name primarily...
assertEquals( 3, paris.getStreets().size() );
assertEquals( chmpsElysees.getStreetName(), paris.getStreets().get( 0 ).getStreetName() );
+ assertEquals( grandeArmee.getStreetName(), paris.getStreets().get( 1 ).getStreetName() );
+ // City.mainStreets is defined to be ordered by street id
List<Street> mainStreets = paris.getMainStreets();
assertEquals( 2, mainStreets.size() );
Integer previousId = new Integer( -1 );
@@ -381,6 +387,7 @@
s.close();
}
+ // HHH-4394
@RequiresDialect(HSQLDialect.class)
public void testOrderByOnSuperclassProperty() {
OrganisationUser user = new OrganisationUser();
Property changes on: core/patches/JBPAPP-7103
___________________________________________________________________
Added: svn:ignore
+ .settings
.project
Modified: core/patches/JBPAPP-7103/core/pom.xml
===================================================================
--- core/patches/JBPAPP-7103/core/pom.xml 2012-08-30 16:38:14 UTC (rev 21059)
+++ core/patches/JBPAPP-7103/core/pom.xml 2012-08-30 16:43:27 UTC (rev 21060)
@@ -83,7 +83,7 @@
<version>${antlrPluginVersion}</version>
<configuration>
<traceTreeParser>true</traceTreeParser>
- <grammars>hql.g,hql-sql.g,sql-gen.g</grammars>
+ <grammars>hql.g,hql-sql.g,sql-gen.g,order-by.g,order-by-render.g</grammars>
</configuration>
<executions>
<execution>
Added: core/patches/JBPAPP-7103/core/src/main/antlr/order-by-render.g
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/antlr/order-by-render.g (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/antlr/order-by-render.g 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,92 @@
+header
+{
+/*
+ * 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
+ *
+ */
+package org.hibernate.sql.ordering.antlr;
+}
+/**
+ * Antlr grammar for rendering <tt>ORDER_BY</tt> trees as described by the {@link OrderByFragmentParser}
+
+ * @author Steve Ebersole
+ */
+class GeneratedOrderByFragmentRenderer extends TreeParser;
+
+options {
+ importVocab=OrderByTemplate;
+ buildAST=false;
+}
+
+{
+ // the buffer to which we write the resulting SQL.
+ private StringBuilder buffer = new StringBuilder();
+
+ protected void out(String text) {
+ buffer.append( text );
+ }
+
+ protected void out(AST ast) {
+ buffer.append( ast.getText() );
+ }
+
+ /*package*/ String getRenderedFragment() {
+ return buffer.toString();
+ }
+}
+
+orderByFragment
+ : #(
+ ORDER_BY sortSpecification ( {out(", ");} sortSpecification)*
+ )
+ ;
+
+sortSpecification
+ : #(
+ SORT_SPEC sortKeySpecification (collationSpecification)? (orderingSpecification)?
+ )
+ ;
+
+sortKeySpecification
+ : #(SORT_KEY sortKey)
+ ;
+
+sortKey
+ : i:IDENT {
+ out( #i );
+ }
+ ;
+
+collationSpecification
+ : c:COLLATE {
+ out( " collate " );
+ out( c );
+ }
+ ;
+
+orderingSpecification
+ : o:ORDER_SPEC {
+ out( " " );
+ out( #o );
+ }
+ ;
\ No newline at end of file
Added: core/patches/JBPAPP-7103/core/src/main/antlr/order-by.g
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/antlr/order-by.g (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/antlr/order-by.g 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,440 @@
+header
+{
+/*
+ * 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
+ *
+ */
+package org.hibernate.sql.ordering.antlr;
+}
+/**
+ * Antlr grammar for dealing with <tt>order-by</tt> mapping fragments.
+
+ * @author Steve Ebersole
+ */
+class GeneratedOrderByFragmentParser extends Parser;
+
+options
+{
+ exportVocab=OrderByTemplate;
+ buildAST=true;
+ k=3;
+}
+
+tokens
+{
+ // synthetic tokens
+ ORDER_BY;
+ SORT_SPEC;
+ ORDER_SPEC;
+ SORT_KEY;
+ EXPR_LIST;
+ DOT;
+ IDENT_LIST;
+ COLUMN_REF;
+
+ COLLATE="collate";
+ ASCENDING="asc";
+ DESCENDING="desc";
+}
+
+
+{
+ /**
+ * Method for logging execution trace information.
+ *
+ * @param msg The trace message.
+ */
+ protected void trace(String msg) {
+ System.out.println( msg );
+ }
+
+ /**
+ * Extract a node's text.
+ *
+ * @param ast The node
+ *
+ * @return The text.
+ */
+ protected final String extractText(AST ast) {
+ // for some reason, within AST creation blocks "[]" I am somtimes unable to refer to the AST.getText() method
+ // using #var (the #var is not interpreted as the rule's output AST).
+ return ast.getText();
+ }
+
+ /**
+ * Process the given node as a quote identifier. These need to be quoted in the dialect-specific way.
+ *
+ * @param ident The quoted-identifier node.
+ *
+ * @return The processed node.
+ *
+ * @see org.hibernate.dialect.Dialect#quote
+ */
+ protected AST quotedIdentifier(AST ident) {
+ return ident;
+ }
+
+ /**
+ * Process the given node as a quote string.
+ *
+ * @param ident The quoted string. This is used from within function param recognition, and represents a
+ * SQL-quoted string.
+ *
+ * @return The processed node.
+ */
+ protected AST quotedString(AST ident) {
+ return ident;
+ }
+
+ /**
+ * A check to see if the text of the given node represents a known function name.
+ *
+ * @param ast The node whose text we want to check.
+ *
+ * @return True if the node's text is a known function name, false otherwise.
+ *
+ * @see org.hibernate.dialect.function.SQLFunctionRegistry
+ */
+ protected boolean isFunctionName(AST ast) {
+ return false;
+ }
+
+ /**
+ * Process the given node as a function.
+ *
+ * @param The node representing the function invocation (including parameters as subtree components).
+ *
+ * @return The processed node.
+ */
+ protected AST resolveFunction(AST ast) {
+ return ast;
+ }
+
+ /**
+ * Process the given node as an IDENT. May represent either a column reference or a property reference.
+ *
+ * @param ident The node whose text represents either a column or property reference.
+ *
+ * @return The processed node.
+ */
+ protected AST resolveIdent(AST ident) {
+ return ident;
+ }
+
+ /**
+ * Allow post processing of each <tt>sort specification</tt>
+ *
+ * @param The grammar-built sort specification subtree.
+ *
+ * @return The processed sort specification subtree.
+ */
+ protected AST postProcessSortSpecification(AST sortSpec) {
+ return sortSpec;
+ }
+
+}
+
+/**
+ * Main recognition rule for this grammar
+ */
+orderByFragment { trace("orderByFragment"); }
+ : sortSpecification ( COMMA! sortSpecification )* {
+ #orderByFragment = #( [ORDER_BY, "order-by"], #orderByFragment );
+ }
+ ;
+
+/**
+ * Recognition rule for what ANSI SQL terms the <tt>sort specification</tt>, which is essentially each thing upon which
+ * the results should be sorted.
+ */
+sortSpecification { trace("sortSpecification"); }
+ : sortKey (collationSpecification)? (orderingSpecification)? {
+ #sortSpecification = #( [SORT_SPEC, "{sort specification}"], #sortSpecification );
+ #sortSpecification = postProcessSortSpecification( #sortSpecification );
+ }
+ ;
+
+/**
+ * Recognition rule for what ANSI SQL terms the <tt>sort key</tt> which is the expression (column, function, etc) upon
+ * which to base the sorting.
+ */
+sortKey! { trace("sortKey"); }
+ : e:expression {
+ #sortKey = #( [SORT_KEY, "sort key"], #e );
+ }
+ ;
+
+/**
+ * Recognition rule what this grammar recognizes as valid <tt>sort key</tt>.
+ */
+expression! { trace("expression"); }
+ : HARD_QUOTE qi:IDENT HARD_QUOTE {
+ #expression = quotedIdentifier( #qi );
+ }
+ | ( IDENT (DOT IDENT)* OPEN_PAREN ) => f:functionCall {
+ #expression = #f;
+ }
+ | p:simplePropertyPath {
+ #expression = resolveIdent( #p );
+ }
+ | i:IDENT {
+ if ( isFunctionName( #i ) ) {
+ #expression = resolveFunction( #i );
+ }
+ else {
+ #expression = resolveIdent( #i );
+ }
+ }
+ ;
+
+/**
+ * Intended for use as a syntactic predicate to determine whether an IDENT represents a known SQL function name.
+ */
+functionCallCheck! { trace("functionCallCheck"); }
+ : IDENT (DOT IDENT)* OPEN_PAREN { true }?
+ ;
+
+/**
+ * Recognition rule for a function call
+ */
+functionCall! { trace("functionCall"); }
+ : fn:functionName OPEN_PAREN pl:functionParameterList CLOSE_PAREN {
+ #functionCall = #( [IDENT, extractText( #fn )], #pl );
+ #functionCall = resolveFunction( #functionCall );
+ }
+ ;
+
+/**
+ * A function-name is an IDENT followed by zero or more (DOT IDENT) sequences
+ */
+functionName {
+ trace("functionName");
+ StringBuilder buffer = new StringBuilder();
+ }
+ : i:IDENT { buffer.append( i.getText() ); }
+ ( DOT i2:IDENT { buffer.append( '.').append( i2.getText() ); } )* {
+ #functionName = #( [IDENT,buffer.toString()] );
+ }
+ ;
+
+/**
+ * Recognition rule used to "wrap" all function parameters into an EXPR_LIST node
+ */
+functionParameterList { trace("functionParameterList"); }
+ : functionParameter ( COMMA! functionParameter )* {
+ #functionParameterList = #( [EXPR_LIST, "{param list}"], #functionParameterList );
+ }
+ ;
+
+/**
+ * Recognized function parameters.
+ */
+functionParameter { trace("functionParameter"); }
+ : expression
+ | NUM_DOUBLE
+ | NUM_FLOAT
+ | NUM_INT
+ | NUM_LONG
+ | QUOTED_STRING {
+ #functionParameter = quotedString( #functionParameter );
+ }
+ ;
+
+/**
+ * Recognition rule for what ANSI SQL terms the <tt>collation specification</tt> used to allow specifying that sorting for
+ * the given {@link #sortSpecification} be treated within a specific character-set.
+ */
+collationSpecification! { trace("collationSpecification"); }
+ : c:COLLATE cn:collationName {
+ #collationSpecification = #( [COLLATE, extractText( #cn )] );
+ }
+ ;
+
+/**
+ * The collation name wrt {@link #collationSpecification}. Namely, the character-set.
+ */
+collationName { trace("collationSpecification"); }
+ : IDENT
+ ;
+
+/**
+ * Recognition rule for what ANSI SQL terms the <tt>ordering specification</tt>; <tt>ASCENDING</tt> or
+ * <tt>DESCENDING</tt>.
+ */
+orderingSpecification! { trace("orderingSpecification"); }
+ : ( "asc" | "ascending" ) {
+ #orderingSpecification = #( [ORDER_SPEC, "asc"] );
+ }
+ | ( "desc" | "descending") {
+ #orderingSpecification = #( [ORDER_SPEC, "desc"] );
+ }
+ ;
+
+/**
+ * A simple-property-path is an IDENT followed by one or more (DOT IDENT) sequences
+ */
+simplePropertyPath {
+ trace("simplePropertyPath");
+ StringBuilder buffer = new StringBuilder();
+ }
+ : i:IDENT { buffer.append( i.getText() ); }
+ ( DOT i2:IDENT { buffer.append( '.').append( i2.getText() ); } )+ {
+ #simplePropertyPath = #( [IDENT,buffer.toString()] );
+ }
+ ;
+
+
+// **** LEXER ******************************************************************
+
+/**
+ * Lexer for the <tt>order-by</tt> fragment parser
+
+ * @author Steve Ebersole
+ * @author Joshua Davis
+ */
+class GeneratedOrderByLexer extends Lexer;
+
+options {
+ exportVocab=OrderByTemplate;
+ testLiterals = false;
+ k=2;
+ charVocabulary='\u0000'..'\uFFFE'; // Allow any char but \uFFFF (16 bit -1, ANTLR's EOF character)
+ caseSensitive = false;
+ caseSensitiveLiterals = false;
+}
+
+// -- Keywords --
+
+OPEN_PAREN: '(';
+CLOSE_PAREN: ')';
+
+COMMA: ',';
+
+HARD_QUOTE: '`';
+
+IDENT options { testLiterals=true; }
+ : ID_START_LETTER ( ID_LETTER )*
+ ;
+
+protected
+ID_START_LETTER
+ : '_'
+ | '$'
+ | 'a'..'z'
+ | '\u0080'..'\ufffe' // HHH-558 : Allow unicode chars in identifiers
+ ;
+
+protected
+ID_LETTER
+ : ID_START_LETTER
+ | '0'..'9'
+ ;
+
+QUOTED_STRING
+ : '\'' ( (ESCqs)=> ESCqs | ~'\'' )* '\''
+ ;
+
+protected
+ESCqs
+ :
+ '\'' '\''
+ ;
+
+//--- From the Java example grammar ---
+// a numeric literal
+NUM_INT
+ {boolean isDecimal=false; Token t=null;}
+ : '.' {_ttype = DOT;}
+ ( ('0'..'9')+ (EXPONENT)? (f1:FLOAT_SUFFIX {t=f1;})?
+ {
+ if (t != null && t.getText().toUpperCase().indexOf('F')>=0)
+ {
+ _ttype = NUM_FLOAT;
+ }
+ else
+ {
+ _ttype = NUM_DOUBLE; // assume double
+ }
+ }
+ )?
+ | ( '0' {isDecimal = true;} // special case for just '0'
+ ( ('x')
+ ( // hex
+ // the 'e'|'E' and float suffix stuff look
+ // like hex digits, hence the (...)+ doesn't
+ // know when to stop: ambig. ANTLR resolves
+ // it correctly by matching immediately. It
+ // is therefore ok to hush warning.
+ options { warnWhenFollowAmbig=false; }
+ : HEX_DIGIT
+ )+
+ | ('0'..'7')+ // octal
+ )?
+ | ('1'..'9') ('0'..'9')* {isDecimal=true;} // non-zero decimal
+ )
+ ( ('l') { _ttype = NUM_LONG; }
+
+ // only check to see if it's a float if looks like decimal so far
+ | {isDecimal}?
+ ( '.' ('0'..'9')* (EXPONENT)? (f2:FLOAT_SUFFIX {t=f2;})?
+ | EXPONENT (f3:FLOAT_SUFFIX {t=f3;})?
+ | f4:FLOAT_SUFFIX {t=f4;}
+ )
+ {
+ if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0)
+ {
+ _ttype = NUM_FLOAT;
+ }
+ else
+ {
+ _ttype = NUM_DOUBLE; // assume double
+ }
+ }
+ )?
+ ;
+
+// hexadecimal digit (again, note it's protected!)
+protected
+HEX_DIGIT
+ : ('0'..'9'|'a'..'f')
+ ;
+
+// a couple protected methods to assist in matching floating point numbers
+protected
+EXPONENT
+ : ('e') ('+'|'-')? ('0'..'9')+
+ ;
+
+protected
+FLOAT_SUFFIX
+ : 'f'|'d'
+ ;
+
+WS : ( ' '
+ | '\t'
+ | '\r' '\n' { newline(); }
+ | '\n' { newline(); }
+ | '\r' { newline(); }
+ )
+ {$setType(Token.SKIP);} //ignore this token
+ ;
Modified: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -72,11 +72,18 @@
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Loadable;
import org.hibernate.persister.entity.PropertyMapping;
+import org.hibernate.persister.entity.Queryable;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.sql.Alias;
import org.hibernate.sql.SelectFragment;
import org.hibernate.sql.SimpleSelect;
import org.hibernate.sql.Template;
+import org.hibernate.sql.ordering.antlr.ColumnMapper;
+import org.hibernate.sql.ordering.antlr.ColumnReference;
+import org.hibernate.sql.ordering.antlr.FormulaReference;
+import org.hibernate.sql.ordering.antlr.OrderByAliasResolver;
+import org.hibernate.sql.ordering.antlr.OrderByTranslation;
+import org.hibernate.sql.ordering.antlr.SqlValueReference;
import org.hibernate.type.AbstractComponentType;
import org.hibernate.type.CollectionType;
import org.hibernate.type.EntityType;
@@ -112,14 +119,17 @@
private final String sqlDetectRowByIndexString;
private final String sqlDetectRowByElementString;
- private final String sqlOrderByString;
protected final String sqlWhereString;
- private final String sqlOrderByStringTemplate;
private final String sqlWhereStringTemplate;
- private final boolean hasOrder;
protected final boolean hasWhere;
private final int baseIndex;
+ private final boolean hasOrder;
+ private final OrderByTranslation orderByTranslation;
+
+ private final boolean hasManyToManyOrder;
+ private final OrderByTranslation manyToManyOrderByTranslation;
+
private final String nodeName;
private final String elementNodeName;
private final String indexNodeName;
@@ -196,9 +206,6 @@
private final String manyToManyWhereString;
private final String manyToManyWhereTemplate;
- private final String manyToManyOrderByString;
- private final String manyToManyOrderByTemplate;
-
// custom sql
private final boolean insertCallable;
private final boolean updateCallable;
@@ -265,12 +272,7 @@
for ( int i = 1; i < spacesSize; i++ ) {
spaces[i] = (String) iter.next();
}
-
- sqlOrderByString = collection.getOrderBy();
- hasOrder = sqlOrderByString != null;
- sqlOrderByStringTemplate = hasOrder ?
- Template.renderOrderByStringTemplate(sqlOrderByString, dialect, factory.getSqlFunctionRegistry()) :
- null;
+
sqlWhereString = StringHelper.isNotEmpty( collection.getWhere() ) ? "( " + collection.getWhere() + ") " : null;
hasWhere = sqlWhereString != null;
sqlWhereStringTemplate = hasWhere ?
@@ -539,6 +541,20 @@
);
}
}
+
+ hasOrder = collection.getOrderBy() != null;
+ if ( hasOrder ) {
+ orderByTranslation = Template.translateOrderBy(
+ collection.getOrderBy(),
+ new ColumnMapperImpl(),
+ factory,
+ dialect,
+ factory.getSqlFunctionRegistry()
+ );
+ }
+ else {
+ orderByTranslation = null;
+ }
// Handle any filters applied to this collection
filterHelper = new FilterHelper( collection.getFilterMap(), dialect, factory.getSqlFunctionRegistry() );
@@ -551,14 +567,79 @@
manyToManyWhereTemplate = manyToManyWhereString == null ?
null :
Template.renderWhereStringTemplate( manyToManyWhereString, factory.getDialect(), factory.getSqlFunctionRegistry() );
- manyToManyOrderByString = collection.getManyToManyOrdering();
- manyToManyOrderByTemplate = manyToManyOrderByString == null
- ? null
- : Template.renderOrderByStringTemplate( manyToManyOrderByString, factory.getDialect(), factory.getSqlFunctionRegistry() );
-
+
+ hasManyToManyOrder = collection.getManyToManyOrdering() != null;
+ if ( hasManyToManyOrder ) {
+ manyToManyOrderByTranslation = Template.translateOrderBy(
+ collection.getManyToManyOrdering(),
+ new ColumnMapperImpl(),
+ factory,
+ dialect,
+ factory.getSqlFunctionRegistry()
+ );
+ }
+ else {
+ manyToManyOrderByTranslation = null;
+ }
+
initCollectionPropertyMap();
}
+
+ private class ColumnMapperImpl implements ColumnMapper {
+ @Override
+ public SqlValueReference[] map(String reference) {
+ final String[] columnNames;
+ final String[] formulaTemplates;
+ // handle the special "$element$" property name...
+ if ( "$element$".equals( reference ) ) {
+ columnNames = elementColumnNames;
+ formulaTemplates = elementFormulaTemplates;
+ }
+ else {
+ columnNames = elementPropertyMapping.toColumns( reference );
+ formulaTemplates = formulaTemplates( reference, columnNames.length );
+ }
+
+ final SqlValueReference[] result = new SqlValueReference[ columnNames.length ];
+ int i = 0;
+ for ( final String columnName : columnNames ) {
+ if ( columnName == null ) {
+ // if the column name is null, it indicates that this index in the property value mapping is
+ // actually represented by a formula.
+ final int propertyIndex = elementPersister.getEntityMetamodel().getPropertyIndex( reference );
+ final String formulaTemplate = formulaTemplates[i];
+ result[i] = new FormulaReference() {
+ @Override
+ public String getFormulaFragment() {
+ return formulaTemplate;
+ }
+ };
+ }
+ else {
+ result[i] = new ColumnReference() {
+ @Override
+ public String getColumnName() {
+ return columnName;
+ }
+ };
+ }
+ i++;
+ }
+ return result;
+ }
+ }
+
+ private String[] formulaTemplates(String reference, int expectedSize) {
+ try {
+ final int propertyIndex = elementPersister.getEntityMetamodel().getPropertyIndex( reference );
+ return ( (Queryable) elementPersister ).getSubclassPropertyFormulaTemplateClosure()[propertyIndex];
+ }
+ catch (Exception e) {
+ return new String[expectedSize];
+ }
+ }
+
public void postInstantiate() throws MappingException {
initializer = queryLoaderName == null ?
createCollectionInitializer( CollectionHelper.EMPTY_MAP ) :
@@ -657,18 +738,17 @@
}
public String getSQLOrderByString(String alias) {
- return hasOrdering() ?
- StringHelper.replace( sqlOrderByStringTemplate, Template.TEMPLATE, alias ) : "";
+ return hasOrdering()
+ ? orderByTranslation.injectAliases( new StandardOrderByAliasResolver( alias ) )
+ : "";
}
public String getManyToManyOrderByString(String alias) {
- if ( isManyToMany() && manyToManyOrderByString != null ) {
- return StringHelper.replace( manyToManyOrderByTemplate, Template.TEMPLATE, alias );
- }
- else {
- return "";
- }
+ return hasManyToManyOrdering()
+ ? manyToManyOrderByTranslation.injectAliases( new StandardOrderByAliasResolver( alias ) )
+ : "";
}
+
public FetchMode getFetchMode() {
return fetchMode;
}
@@ -678,7 +758,7 @@
}
public boolean hasManyToManyOrdering() {
- return isManyToMany() && manyToManyOrderByTemplate != null;
+ return isManyToMany() && hasManyToManyOrder;
}
public boolean hasWhere() {
@@ -1804,4 +1884,23 @@
protected Dialect getDialect() {
return dialect;
}
+
+ private class StandardOrderByAliasResolver implements OrderByAliasResolver {
+ private final String rootAlias;
+
+ private StandardOrderByAliasResolver(String rootAlias) {
+ this.rootAlias = rootAlias;
+ }
+
+ @Override
+ public String resolveTableAlias(String columnReference) {
+ if ( elementPersister == null ) {
+ // we have collection of non-entity elements...
+ return rootAlias;
+ }
+ else {
+ return ( (Loadable) elementPersister ).getTableAliasForColumn( columnReference, rootAlias );
+ }
+ }
+ }
}
Modified: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -1607,7 +1607,8 @@
return propertyDefinedOnSubclass[i];
}
- protected String[][] getSubclassPropertyFormulaTemplateClosure() {
+ @Override
+ public String[][] getSubclassPropertyFormulaTemplateClosure() {
return subclassPropertyFormulaTemplateClosure;
}
@@ -3959,6 +3960,14 @@
throws HibernateException {
getTuplizer( entityMode ).setPropertyValue( object, propertyName, value );
}
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ @Override
+ public String getTableAliasForColumn(String columnName, String rootAlias) {
+ return generateTableAlias( rootAlias, determineTableNumberForColumn( columnName ) );
+ }
+ public int determineTableNumberForColumn(String columnName) {
+ return 0;
+ }
+
}
Modified: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -604,4 +604,24 @@
}
return super.getSubclassPropertyDeclarer( propertyPath );
}
+
+ @Override
+ public int determineTableNumberForColumn(String columnName) {
+ final String[] subclassColumnNameClosure = getSubclassColumnClosure();
+ for ( int i = 0, max = subclassColumnNameClosure.length; i < max; i++ ) {
+ final boolean quoted = subclassColumnNameClosure[i].startsWith( "\"" )
+ && subclassColumnNameClosure[i].endsWith( "\"" );
+ if ( quoted ) {
+ if ( subclassColumnNameClosure[i].equals( columnName ) ) {
+ return getSubclassColumnTableNumberClosure()[i];
+ }
+ }
+ else {
+ if ( subclassColumnNameClosure[i].equalsIgnoreCase( columnName ) ) {
+ return getSubclassColumnTableNumberClosure()[i];
+ }
+ }
+ }
+ throw new HibernateException( "Could not locate table which owns column [" + columnName + "] referenced in order-by mapping" );
+ }
}
Modified: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/Loadable.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/Loadable.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/Loadable.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -108,4 +108,18 @@
public boolean isAbstract();
+ /**
+ * Given a column name and the root table alias in use for the entity hierarchy, determine the proper table alias
+ * for the table in that hierarchy that contains said column.
+ * <p/>
+ * NOTE : Generally speaking the column is not validated to exist. Most implementations simply return the
+ * root alias; the exception is {@link JoinedSubclassEntityPersister}
+ *
+ * @param columnName The column name
+ * @param rootAlias The hierarchy root alias
+ *
+ * @return The proper table alias for qualifying the given column.
+ */
+ public String getTableAliasForColumn(String columnName, String rootAlias);
+
}
Modified: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/Queryable.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/Queryable.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/persister/entity/Queryable.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -162,6 +162,8 @@
*/
public String generateFilterConditionAlias(String rootAlias);
+ String[][] getSubclassPropertyFormulaTemplateClosure();
+
public static class Declarer {
public static final Declarer CLASS = new Declarer( "class" );
public static final Declarer SUBCLASS = new Declarer( "subclass" );
Modified: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/Template.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/Template.java 2012-08-30 16:38:14 UTC (rev 21059)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/Template.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -29,6 +29,13 @@
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.SQLFunctionRegistry;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.sql.ordering.antlr.ColumnMapper;
+import org.hibernate.sql.ordering.antlr.OrderByAliasResolver;
+import org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator;
+import org.hibernate.sql.ordering.antlr.OrderByTranslation;
+import org.hibernate.sql.ordering.antlr.SqlValueReference;
+import org.hibernate.sql.ordering.antlr.TranslationContext;
import org.hibernate.util.StringHelper;
/**
@@ -233,91 +240,100 @@
return result.toString();
}
+ public static class NoOpColumnMapper implements ColumnMapper {
+ public static final NoOpColumnMapper INSTANCE = new NoOpColumnMapper();
+ public SqlValueReference[] map(String reference) {
+ // return new String[] { reference };
+ return null;
+ }
+ }
+
/**
- * Takes order by clause provided in the mapping attribute and interpolates the alias.
- * Handles asc, desc, SQL functions, quoted identifiers.
+ * Performs order-by template rendering without {@link ColumnMapper column mapping}. An <tt>ORDER BY</tt> template
+ * has all column references "qualified" with a placeholder identified by {@link Template#TEMPLATE}
+ *
+ * @param orderByFragment The order-by fragment to render.
+ * @param dialect The SQL dialect being used.
+ * @param functionRegistry The SQL function registry
+ *
+ * @return The rendered <tt>ORDER BY</tt> template.
+ *
+ * @deprecated Use {@link #translateOrderBy} instead
*/
- public static String renderOrderByStringTemplate(String sqlOrderByString, Dialect dialect, SQLFunctionRegistry functionRegistry) {
- //TODO: make this a bit nicer
- String symbols = new StringBuffer()
- .append("=><!+-*/()',|&`")
- .append(StringHelper.WHITESPACE)
- .append( dialect.openQuote() )
- .append( dialect.closeQuote() )
- .toString();
- StringTokenizer tokens = new StringTokenizer(sqlOrderByString, symbols, true);
-
- StringBuffer result = new StringBuffer();
- boolean quoted = false;
- boolean quotedIdentifier = false;
-
- boolean hasMore = tokens.hasMoreTokens();
- String nextToken = hasMore ? tokens.nextToken() : null;
- while (hasMore) {
- String token = nextToken;
- String lcToken = token.toLowerCase();
- hasMore = tokens.hasMoreTokens();
- nextToken = hasMore ? tokens.nextToken() : null;
-
- boolean isQuoteCharacter = false;
-
- if ( !quotedIdentifier && "'".equals(token) ) {
- quoted = !quoted;
- isQuoteCharacter = true;
+ @Deprecated
+ public static String renderOrderByStringTemplate(
+ String orderByFragment,
+ Dialect dialect,
+ SQLFunctionRegistry functionRegistry) {
+ return renderOrderByStringTemplate(
+ orderByFragment,
+ NoOpColumnMapper.INSTANCE,
+ null,
+ dialect,
+ functionRegistry
+ );
+ }
+
+ public static String renderOrderByStringTemplate(
+ String orderByFragment,
+ final ColumnMapper columnMapper,
+ final SessionFactoryImplementor sessionFactory,
+ final Dialect dialect,
+ final SQLFunctionRegistry functionRegistry) {
+ return translateOrderBy(
+ orderByFragment,
+ columnMapper,
+ sessionFactory,
+ dialect,
+ functionRegistry
+ ).injectAliases( LEGACY_ORDER_BY_ALIAS_RESOLVER );
+ }
+
+ public static OrderByAliasResolver LEGACY_ORDER_BY_ALIAS_RESOLVER = new OrderByAliasResolver() {
+ @Override
+ public String resolveTableAlias(String columnReference) {
+ return TEMPLATE;
+ }
+ };
+
+ /**
+ * Performs order-by template rendering allowing {@link ColumnMapper column mapping}. An <tt>ORDER BY</tt> template
+ * has all column references "qualified" with a placeholder identified by {@link Template#TEMPLATE} which can later
+ * be used to easily inject the SQL alias.
+ *
+ * @param orderByFragment The order-by fragment to render.
+ * @param columnMapper The column mapping strategy to use.
+ * @param sessionFactory The session factory.
+ * @param dialect The SQL dialect being used.
+ * @param functionRegistry The SQL function registry
+ *
+ * @return The rendered <tt>ORDER BY</tt> template.
+ */
+ public static OrderByTranslation translateOrderBy(
+ String orderByFragment,
+ final ColumnMapper columnMapper,
+ final SessionFactoryImplementor sessionFactory,
+ final Dialect dialect,
+ final SQLFunctionRegistry functionRegistry) {
+ TranslationContext context = new TranslationContext() {
+ public SessionFactoryImplementor getSessionFactory() {
+ return sessionFactory;
}
-
- if ( !quoted ) {
-
- boolean isOpenQuote;
- if ( "`".equals(token) ) {
- isOpenQuote = !quotedIdentifier;
- token = lcToken = isOpenQuote ?
- new Character( dialect.openQuote() ).toString() :
- new Character( dialect.closeQuote() ).toString();
- quotedIdentifier = isOpenQuote;
- isQuoteCharacter = true;
- }
- else if ( !quotedIdentifier && ( dialect.openQuote()==token.charAt(0) ) ) {
- isOpenQuote = true;
- quotedIdentifier = true;
- isQuoteCharacter = true;
- }
- else if ( quotedIdentifier && ( dialect.closeQuote()==token.charAt(0) ) ) {
- quotedIdentifier = false;
- isQuoteCharacter = true;
- isOpenQuote = false;
- }
- else {
- isOpenQuote = false;
- }
-
- if (isOpenQuote) {
- result.append(TEMPLATE).append('.');
- }
-
+
+ public Dialect getDialect() {
+ return dialect;
}
-
- boolean quotedOrWhitespace = quoted ||
- quotedIdentifier ||
- isQuoteCharacter ||
- Character.isWhitespace( token.charAt(0) );
-
- if (quotedOrWhitespace) {
- result.append(token);
+
+ public SQLFunctionRegistry getSqlFunctionRegistry() {
+ return functionRegistry;
}
- else if (
- isIdentifier(token, dialect) &&
- !isFunctionOrKeyword(lcToken, nextToken, dialect, functionRegistry)
- ) {
- result.append(TEMPLATE)
- .append('.')
- .append( dialect.quote(token) );
+
+ public ColumnMapper getColumnMapper() {
+ return columnMapper;
}
- else {
- result.append(token);
- }
- }
- return result.toString();
+ };
+
+ return OrderByFragmentTranslator.translate( context, orderByFragment );
}
private static boolean isNamedParameter(String token) {
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/CollationSpecification.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/CollationSpecification.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/CollationSpecification.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,33 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * Models a collation specification (<tt>COLLATE</tt> using a specific character-set) within a
+ * {@link SortSpecification}.
+ *
+ * @author Steve Ebersole
+ */
+public class CollationSpecification extends NodeSupport {
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/ColumnMapper.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/ColumnMapper.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/ColumnMapper.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,46 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Contract for mapping a (an assumed) property reference to its columns.
+ *
+ * @author Steve Ebersole
+ */
+public interface ColumnMapper {
+ /**
+ * Resolve the property reference to its underlying columns.
+ *
+ * @param reference The property reference name.
+ *
+ * @return References to the columns/formulas that define the value mapping for the given property, or null
+ * if the property reference is unknown.
+ *
+ * @throws HibernateException Generally indicates that the property reference is unknown; interpretation
+ * should be the same as a null return.
+ */
+ public SqlValueReference[] map(String reference) throws HibernateException;
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/ColumnReference.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/ColumnReference.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/ColumnReference.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,38 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * Reference to a column name.
+ *
+ * @author Steve Ebersole
+ */
+public interface ColumnReference extends SqlValueReference {
+ /**
+ * Retrieve the column name.
+ *
+ * @return THe column name
+ */
+ public String getColumnName();
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/Factory.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/Factory.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/Factory.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,51 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+import antlr.ASTFactory;
+
+/**
+ * Acts as a {@link ASTFactory} for injecting our specific AST node classes into the Antlr generated trees.
+ *
+ * @author Steve Ebersole
+ */
+public class Factory extends ASTFactory implements OrderByTemplateTokenTypes {
+ @Override
+ public Class getASTNodeType(int i) {
+ switch ( i ) {
+ case ORDER_BY:
+ return OrderByFragment.class;
+ case SORT_SPEC:
+ return SortSpecification.class;
+ case ORDER_SPEC:
+ return OrderingSpecification.class;
+ case COLLATE:
+ return CollationSpecification.class;
+ case SORT_KEY:
+ return SortKey.class;
+ default:
+ return NodeSupport.class;
+ }
+ }
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/FormulaReference.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/FormulaReference.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/FormulaReference.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,40 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * Reference to a formula fragment.
+ *
+ * @author Steve Ebersole
+ */
+public interface FormulaReference extends SqlValueReference {
+ /**
+ * Retrieve the formula fragment. It is important to note that this is what the persister calls the
+ * "formula template", which has the $PlaceHolder$ (see {@link org.hibernate.sql.Template#TEMPLATE})
+ * markers injected.
+ *
+ * @return The formula fragment template.
+ */
+ public String getFormulaFragment();
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/Node.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/Node.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/Node.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,52 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * General contract for AST nodes.
+ *
+ * @author Steve Ebersole
+ */
+public interface Node {
+ /**
+ * Get the intrinsic text of this node.
+ *
+ * @return The node's text.
+ */
+ public String getText();
+
+ /**
+ * Get a string representation of this node usable for debug logging or similar.
+ *
+ * @return The node's debugging text.
+ */
+ public String getDebugText();
+
+ /**
+ * Build the node's representation for use in the resulting rendering.
+ *
+ * @return The text for use in the translated output.
+ */
+ public String getRenderableText();
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/NodeSupport.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/NodeSupport.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/NodeSupport.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,43 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+import antlr.CommonAST;
+
+/**
+ * Basic implementation of a {@link Node} briding to the Antlr {@link CommonAST} hierarchy.
+ *
+ * @author Steve Ebersole
+ */
+public class NodeSupport extends CommonAST implements Node {
+ @Override
+ public String getDebugText() {
+ return getText();
+ }
+
+ @Override
+ public String getRenderableText() {
+ return getText();
+ }
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByAliasResolver.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByAliasResolver.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByAliasResolver.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,35 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * Given a column reference, resolve the table alias to apply to the column to qualify it.
+ */
+public interface OrderByAliasResolver {
+ /**
+ * Given a column reference, resolve the table alias to apply to the column to qualify it.
+ *
+ */
+ public String resolveTableAlias(String columnReference);
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragment.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragment.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragment.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,32 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * Represents a parsed <tt>order-by</tt> mapping fragment. This holds the tree of all {@link SortSpecification}s.
+ *
+ * @author Steve Ebersole
+ */
+public class OrderByFragment extends NodeSupport {
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,299 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.sql.Template;
+
+import antlr.CommonAST;
+import antlr.TokenStream;
+import antlr.collections.AST;
+
+/**
+ * Extension of the Antlr-generated parser for the purpose of adding our custom parsing behavior
+ * (semantic analysis, etc).
+ *
+ * @author Steve Ebersole
+ */
+public class OrderByFragmentParser extends GeneratedOrderByFragmentParser {
+ private final TranslationContext context;
+
+ private Set<String> columnReferences = new HashSet<String>();
+
+ public OrderByFragmentParser(TokenStream lexer, TranslationContext context) {
+ super( lexer );
+ super.setASTFactory( new Factory() );
+ this.context = context;
+ }
+
+ public Set<String> getColumnReferences() {
+ return columnReferences;
+ }
+
+ @Override
+ protected AST quotedIdentifier(AST ident) {
+ /*
+ * Semantic action used during recognition of quoted identifiers (quoted column names)
+ */
+ final String columnName = context.getDialect().quote( '`' + ident.getText() + '`' );
+ columnReferences.add( columnName );
+ final String marker = '{' + columnName + '}';
+ return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, marker );
+ }
+
+ @Override
+ protected AST quotedString(AST ident) {
+ /*
+ * Semantic action used during recognition of quoted strings (string literals)
+ */
+ return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, context.getDialect().quote( ident.getText() ) );
+ }
+
+ @Override
+ @SuppressWarnings("SimplifiableIfStatement")
+ protected boolean isFunctionName(AST ast) {
+ /*
+ * Semantic predicate used to determine whether a given AST node represents a function call
+ */
+
+ AST child = ast.getFirstChild();
+ // assume it is a function if it has parameters
+ if ( child != null && "{param list}".equals( child.getText() ) ) {
+ return true;
+ }
+
+ // otherwise, in order for this to be a function logically it has to be a function that does not
+ // have arguments. So try to assert that using the registry of known functions
+ final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( ast.getText() );
+ if ( function == null ) {
+ // no registered function, so we cannot know for certain
+ return false;
+ }
+ else {
+ // if function.hasParenthesesIfNoArguments() is true, then assume the node is not a function
+ return ! function.hasParenthesesIfNoArguments();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected AST resolveFunction(AST ast) {
+ /*
+ * Semantic action used during recognition of a *known* function
+ */
+ AST child = ast.getFirstChild();
+ if ( child != null ) {
+ assert "{param list}".equals( child.getText() );
+ child = child.getFirstChild();
+ }
+
+ final String functionName = ast.getText();
+ final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( functionName );
+ if ( function == null ) {
+ String text = functionName;
+ if ( child != null ) {
+ text += '(';
+ while ( child != null ) {
+ text += resolveFunctionArgument( child );
+ child = child.getNextSibling();
+ if ( child != null ) {
+ text += ", ";
+ }
+ }
+ text += ')';
+ }
+ return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, text );
+ }
+ else {
+ ArrayList expressions = new ArrayList();
+ while ( child != null ) {
+ expressions.add( resolveFunctionArgument( child ) );
+ child = child.getNextSibling();
+ }
+ final String text = function.render( expressions, context.getSessionFactory() );
+ return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, text );
+ }
+ }
+
+ private String resolveFunctionArgument(AST argumentNode) {
+ final String nodeText = argumentNode.getText();
+ final String adjustedText;
+ if ( nodeText.contains( Template.TEMPLATE ) ) {
+ // we have a SQL order-by fragment
+ adjustedText = adjustTemplateReferences( nodeText );
+ }
+ else if ( nodeText.startsWith( "{" ) && nodeText.endsWith( "}" ) ) {
+ columnReferences.add( nodeText.substring( 1, nodeText.length() - 1 ) );
+ return nodeText;
+ }
+ else {
+ adjustedText = nodeText;
+ // because we did not process the node text, we need to attempt to find any column references
+ // contained in it.
+ // NOTE : uses regex for the time being; we should check the performance of this
+ Pattern pattern = Pattern.compile( "\\{(.*)\\}" );
+ Matcher matcher = pattern.matcher( adjustedText );
+ while ( matcher.find() ) {
+ columnReferences.add( matcher.group( 1 ) );
+ }
+ }
+ return adjustedText;
+ }
+
+ @Override
+ protected AST resolveIdent(AST ident) {
+ /*
+ * Semantic action used during recognition of an identifier. This identifier might be a column name, it might
+ * be a property name.
+ */
+ String text = ident.getText();
+ SqlValueReference[] sqlValueReferences;
+ try {
+ sqlValueReferences = context.getColumnMapper().map( text );
+ }
+ catch( Throwable t ) {
+ sqlValueReferences = null;
+ }
+
+ if ( sqlValueReferences == null || sqlValueReferences.length == 0 ) {
+ return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, makeColumnReference( text ) );
+ }
+ else if ( sqlValueReferences.length == 1 ) {
+ return processSqlValueReference( sqlValueReferences[0] );
+ }
+ else {
+ final AST root = getASTFactory().create( OrderByTemplateTokenTypes.IDENT_LIST, "{ident list}" );
+ for ( SqlValueReference sqlValueReference : sqlValueReferences ) {
+ root.addChild( processSqlValueReference( sqlValueReference ) );
+ }
+ return root;
+ }
+ }
+
+ private AST processSqlValueReference(SqlValueReference sqlValueReference) {
+ if ( ColumnReference.class.isInstance( sqlValueReference ) ) {
+ final String columnName = ( (ColumnReference) sqlValueReference ).getColumnName();
+ return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, makeColumnReference( columnName ) );
+ }
+ else {
+ final String formulaFragment = ( (FormulaReference) sqlValueReference ).getFormulaFragment();
+ // formulas have already been "adjusted" for aliases by appending Template.TEMPLATE to places
+ // where we believe column references are. Fixing that is beyond scope of this work. But we need
+ // to re-adjust that to use the order-by expectation of wrapping the column names in curly
+ // braces (i.e., `{column_name}`).
+ final String adjustedText = adjustTemplateReferences( formulaFragment );
+ return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, adjustedText );
+ }
+ }
+
+ private String makeColumnReference(String text) {
+ columnReferences.add( text );
+ return "{" + text + "}";
+ }
+
+ private static final int TEMPLATE_MARKER_LENGTH = Template.TEMPLATE.length();
+
+ private String adjustTemplateReferences(String template) {
+ int templateLength = template.length();
+ int startPos = template.indexOf( Template.TEMPLATE );
+ while ( startPos < templateLength ) {
+ int dotPos = startPos + TEMPLATE_MARKER_LENGTH;
+
+ // from here we need to seek the end of the qualified identifier
+ int pos = dotPos + 1;
+ while ( pos < templateLength && isValidIdentifierCharacter( template.charAt( pos ) ) ) {
+ pos++;
+ }
+
+ // At this point we know all 3 points in the template that are needed for replacement.
+ // Basically we will be replacing the whole match with the bit following the dot, but will wrap
+ // the replacement in curly braces.
+ final String columnReference = template.substring( dotPos + 1, pos );
+ final String replacement = "{" + columnReference + "}";
+ template = template.replace( template.substring( startPos, pos ), replacement );
+ columnReferences.add( columnReference );
+
+ // prep for the next seek
+ startPos = ( pos - TEMPLATE_MARKER_LENGTH ) + 1;
+ templateLength = template.length();
+ }
+
+ return template;
+ }
+
+ private static boolean isValidIdentifierCharacter(char c) {
+ return Character.isLetter( c )
+ || Character.isDigit( c )
+ || '_' == c
+ || '\"' == c;
+ }
+
+ @Override
+ protected AST postProcessSortSpecification(AST sortSpec) {
+ assert SORT_SPEC == sortSpec.getType();
+ SortSpecification sortSpecification = ( SortSpecification ) sortSpec;
+ AST sortKey = sortSpecification.getSortKey();
+ if ( IDENT_LIST == sortKey.getFirstChild().getType() ) {
+ AST identList = sortKey.getFirstChild();
+ AST ident = identList.getFirstChild();
+ AST holder = new CommonAST();
+ do {
+ holder.addChild(
+ createSortSpecification(
+ ident,
+ sortSpecification.getCollation(),
+ sortSpecification.getOrdering()
+ )
+ );
+ ident = ident.getNextSibling();
+ } while ( ident != null );
+ sortSpec = holder.getFirstChild();
+ }
+ return sortSpec;
+ }
+
+ private SortSpecification createSortSpecification(
+ AST ident,
+ CollationSpecification collationSpecification,
+ OrderingSpecification orderingSpecification) {
+ AST sortSpecification = getASTFactory().create( SORT_SPEC, "{{sort specification}}" );
+ AST sortKey = getASTFactory().create( SORT_KEY, "{{sort key}}" );
+ AST newIdent = getASTFactory().create( ident.getType(), ident.getText() );
+ sortKey.setFirstChild( newIdent );
+ sortSpecification.setFirstChild( sortKey );
+ if ( collationSpecification != null ) {
+ sortSpecification.addChild( collationSpecification );
+ }
+ if ( orderingSpecification != null ) {
+ sortSpecification.addChild( orderingSpecification );
+ }
+ return ( SortSpecification ) sortSpecification;
+ }
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentRenderer.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentRenderer.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentRenderer.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+import antlr.collections.AST;
+
+/**
+ * Extension of the Antlr-generated tree walker for rendering the parsed order-by tree back to String form.
+ * {@link #out(antlr.collections.AST)} is the sole semantic action here and it is used to utilize our
+ * split between text (tree debugging text) and "renderable text" (text to use during rendering).
+ *
+ * @author Steve Ebersole
+ */
+public class OrderByFragmentRenderer extends GeneratedOrderByFragmentRenderer {
+
+ @Override
+ protected void out(AST ast) {
+ out( ( ( Node ) ast ).getRenderableText() );
+ }
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentTranslator.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentTranslator.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentTranslator.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,104 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+import java.io.StringReader;
+import java.util.Set;
+
+import org.hibernate.HibernateException;
+
+/**
+ * A translator for order-by mappings, whether specified by hbm.xml files, Hibernate
+ * {@link org.hibernate.annotations.OrderBy} annotation or JPA {@link javax.persistence.OrderBy} annotation.
+ *
+ * @author Steve Ebersole
+ */
+public class OrderByFragmentTranslator {
+ /**
+ * Perform the translation of the user-supplied fragment, returning the translation.
+ * <p/>
+ * The important distinction to this split between (1) translating and (2) resolving aliases is that
+ * both happen at different times
+ *
+ *
+ * @param context Context giving access to delegates needed during translation.
+ * @param fragment The user-supplied order-by fragment
+ *
+ * @return The translation.
+ */
+ public static OrderByTranslation translate(TranslationContext context, String fragment) {
+ GeneratedOrderByLexer lexer = new GeneratedOrderByLexer( new StringReader( fragment ) );
+
+ // Perform the parsing (and some analysis/resolution). Another important aspect is the collection
+ // of "column references" which are important later to seek out replacement points in the
+ // translated fragment.
+ OrderByFragmentParser parser = new OrderByFragmentParser( lexer, context );
+ try {
+ parser.orderByFragment();
+ }
+ catch ( HibernateException e ) {
+ throw e;
+ }
+ catch ( Throwable t ) {
+ throw new HibernateException( "Unable to parse order-by fragment", t );
+ }
+
+ // Render the parsed tree to text.
+ OrderByFragmentRenderer renderer = new OrderByFragmentRenderer();
+ try {
+ renderer.orderByFragment( parser.getAST() );
+ }
+ catch ( HibernateException e ) {
+ throw e;
+ }
+ catch ( Throwable t ) {
+ throw new HibernateException( "Unable to render parsed order-by fragment", t );
+ }
+
+ return new StandardOrderByTranslationImpl( renderer.getRenderedFragment(), parser.getColumnReferences() );
+ }
+
+ public static class StandardOrderByTranslationImpl implements OrderByTranslation {
+ private final String sqlTemplate;
+ private final Set<String> columnReferences;
+
+ public StandardOrderByTranslationImpl(String sqlTemplate, Set<String> columnReferences) {
+ this.sqlTemplate = sqlTemplate;
+ this.columnReferences = columnReferences;
+ }
+
+ @Override
+ public String injectAliases(OrderByAliasResolver aliasResolver) {
+ String sql = sqlTemplate;
+ for ( String columnReference : columnReferences ) {
+ final String replacementToken = "{" + columnReference + "}";
+ sql = sql.replace(
+ replacementToken,
+ aliasResolver.resolveTableAlias( columnReference ) + '.' + columnReference
+ );
+ }
+ return sql;
+ }
+ }
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByTranslation.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByTranslation.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByTranslation.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * Represents the result of an order-by translation by {@link @OrderByTranslator}
+ *
+ * @author Steve Ebersole
+ */
+public interface OrderByTranslation {
+ /**
+ * Inject table aliases into the translated fragment to properly qualify column references, using
+ * the given 'aliasResolver' to determine the the proper table alias to use for each column reference.
+ *
+ * @param aliasResolver The strategy to resolver the proper table alias to use per column
+ *
+ * @return The fully translated and replaced fragment.
+ */
+ public String injectAliases(OrderByAliasResolver aliasResolver);
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderingSpecification.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderingSpecification.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderingSpecification.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,69 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * Models an ordering specification (<tt>ASCENDING</tt> or <tt>DESCENDING</tt>) within a {@link SortSpecification}.
+ *
+ * @author Steve Ebersole
+ */
+public class OrderingSpecification extends NodeSupport {
+ public static class Ordering {
+ public static final Ordering ASCENDING = new Ordering( "asc" );
+ public static final Ordering DESCENDING = new Ordering( "desc" );
+
+ private final String name;
+
+ private Ordering(String name) {
+ this.name = name;
+ }
+ }
+
+ private boolean resolved;
+ private Ordering ordering;
+
+ public Ordering getOrdering() {
+ if ( !resolved ) {
+ ordering = resolve( getText() );
+ resolved = true;
+ }
+ return ordering;
+ }
+
+ private static Ordering resolve(String text) {
+ if ( Ordering.ASCENDING.name.equals( text ) ) {
+ return Ordering.ASCENDING;
+ }
+ else if ( Ordering.DESCENDING.name.equals( text ) ) {
+ return Ordering.DESCENDING;
+ }
+ else {
+ throw new IllegalStateException( "Unknown ordering [" + text + "]" );
+ }
+ }
+
+ public String getRenderableText() {
+ return getOrdering().name;
+ }
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SortKey.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SortKey.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SortKey.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+
+/**
+ * Models the container node for the <tt>sort key</tt>, which is the term given by the ANSI SQL specification to the
+ * expression upon which to sort for each {@link SortSpecification}
+ *
+ * @author Steve Ebersole
+ */
+public class SortKey extends NodeSupport {
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SortSpecification.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SortSpecification.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SortSpecification.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,79 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+import antlr.collections.AST;
+
+/**
+ * Models each sorting expression.
+ *
+ * @author Steve Ebersole
+ */
+public class SortSpecification extends NodeSupport {
+ /**
+ * Locate the specified {@link SortKey}.
+ *
+ * @return The sort key.
+ */
+ public SortKey getSortKey() {
+ return ( SortKey ) getFirstChild();
+ }
+
+ /**
+ * Locate the specified <tt>collation specification</tt>, if one.
+ *
+ * @return The <tt>collation specification</tt>, or null if none was specified.
+ */
+ public CollationSpecification getCollation() {
+ AST possible = getSortKey().getNextSibling();
+ return possible != null && OrderByTemplateTokenTypes.COLLATE == possible.getType()
+ ? ( CollationSpecification ) possible
+ : null;
+ }
+
+ /**
+ * Locate the specified <tt>ordering specification</tt>, if one.
+ *
+ * @return The <tt>ordering specification</tt>, or null if none was specified.
+ */
+ public OrderingSpecification getOrdering() {
+ // IMPL NOTE : the ordering-spec would be either the 2nd or 3rd child (of the overall sort-spec), if it existed,
+ // depending on whether a collation-spec was specified.
+
+ AST possible = getSortKey().getNextSibling();
+ if ( possible == null ) {
+ // There was no sort-spec parts specified other then the sort-key so there can be no ordering-spec...
+ return null;
+ }
+
+ if ( OrderByTemplateTokenTypes.COLLATE == possible.getType() ) {
+ // the 2nd child was a collation-spec, so we need to check the 3rd child instead.
+ possible = possible.getNextSibling();
+ }
+
+ return possible != null && OrderByTemplateTokenTypes.ORDER_SPEC == possible.getType()
+ ? ( OrderingSpecification ) possible
+ : null;
+ }
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SqlValueReference.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SqlValueReference.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/SqlValueReference.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,36 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2012, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+/**
+ * Unifying interface between column and formula references mainly to give more strictly typed result
+ * to {@link ColumnMapper#map(String)}
+ *
+ * @see ColumnReference
+ * @see FormulaReference
+ *
+ * @author Steve Ebersole
+ */
+public interface SqlValueReference {
+}
Added: core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/TranslationContext.java
===================================================================
--- core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/TranslationContext.java (rev 0)
+++ core/patches/JBPAPP-7103/core/src/main/java/org/hibernate/sql/ordering/antlr/TranslationContext.java 2012-08-30 16:43:27 UTC (rev 21060)
@@ -0,0 +1,63 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008 Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.sql.ordering.antlr;
+
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.function.SQLFunctionRegistry;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+/**
+ * Contract for contextual information required to perform translation.
+*
+* @author Steve Ebersole
+*/
+public interface TranslationContext {
+ /**
+ * Retrieves the <tt>session factory</tt> for this context.
+ *
+ * @return The <tt>session factory</tt>
+ */
+ public SessionFactoryImplementor getSessionFactory();
+
+ /**
+ * Retrieves the <tt>dialect</tt> for this context.
+ *
+ * @return The <tt>dialect</tt>
+ */
+ public Dialect getDialect();
+
+ /**
+ * Retrieves the <tt>SQL function registry/tt> for this context.
+ *
+ * @return The SQL function registry.
+ */
+ public SQLFunctionRegistry getSqlFunctionRegistry();
+
+ /**
+ * Retrieves the <tt>column mapper</tt> for this context.
+ *
+ * @return The <tt>column mapper</tt>
+ */
+ public ColumnMapper getColumnMapper();
+}
12 years, 7 months
Hibernate SVN: r21059 - core/patches/JBPAPP-7103.
by hibernate-commits@lists.jboss.org
Author: brmeyer
Date: 2012-08-30 12:38:14 -0400 (Thu, 30 Aug 2012)
New Revision: 21059
Added:
core/patches/JBPAPP-7103/cache-ehcache/
core/patches/JBPAPP-7103/cache-jbosscache2/
core/patches/JBPAPP-7103/cache-oscache/
core/patches/JBPAPP-7103/cache-swarmcache/
core/patches/JBPAPP-7103/connection-c3p0/
core/patches/JBPAPP-7103/connection-proxool/
core/patches/JBPAPP-7103/core/
core/patches/JBPAPP-7103/distribution/
core/patches/JBPAPP-7103/etc/
core/patches/JBPAPP-7103/hibernate_logo.gif
core/patches/JBPAPP-7103/jdbc3-testing/
core/patches/JBPAPP-7103/jdbc4-testing/
core/patches/JBPAPP-7103/jmx/
core/patches/JBPAPP-7103/lgpl.txt
core/patches/JBPAPP-7103/parent/
core/patches/JBPAPP-7103/pom.xml
core/patches/JBPAPP-7103/testing/
core/patches/JBPAPP-7103/testsuite/
core/patches/JBPAPP-7103/tutorials/
Log:
Branching for JBPAPP-7103
Copied: core/patches/JBPAPP-7103/hibernate_logo.gif (from rev 21058, core/branches/Branch_3_3_2_GA_CP/hibernate_logo.gif)
===================================================================
(Binary files differ)
Copied: core/patches/JBPAPP-7103/lgpl.txt (from rev 21058, core/branches/Branch_3_3_2_GA_CP/lgpl.txt)
===================================================================
--- core/patches/JBPAPP-7103/lgpl.txt (rev 0)
+++ core/patches/JBPAPP-7103/lgpl.txt 2012-08-30 16:38:14 UTC (rev 21059)
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
Copied: core/patches/JBPAPP-7103/pom.xml (from rev 21058, core/branches/Branch_3_3_2_GA_CP/pom.xml)
===================================================================
--- core/patches/JBPAPP-7103/pom.xml (rev 0)
+++ core/patches/JBPAPP-7103/pom.xml 2012-08-30 16:38:14 UTC (rev 21059)
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Inc.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.2.GA_CP05</version>
+ <relativePath>parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Hibernate Core Aggregator</name>
+ <description>Aggregator of the Hibernate Core modules.</description>
+
+ <modules>
+ <module>parent</module>
+ <module>core</module>
+ <module>cache-ehcache</module>
+ <module>cache-jbosscache2</module>
+ <module>cache-oscache</module>
+ <module>cache-swarmcache</module>
+ <module>connection-c3p0</module>
+ <module>connection-proxool</module>
+ <module>jdbc4-testing</module>
+ <module>jdbc3-testing</module>
+ <module>jmx</module>
+ <module>testing</module>
+ <module>testsuite</module>
+ <module>tutorials</module>
+ <module>distribution</module>
+ </modules>
+
+ <scm>
+ <connection>scm:svn:https://svn.jboss.org/repos/hibernate/core/tags/hibernate-3.3.2.G...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/hibernate/core/tags/hibernate-3.3.2.G...</developerConnection>
+ <url>https://svn.jboss.org/repos/hibernate/core/tags/hibernate-3.3.2.GA_CP05</url>
+ </scm>
+</project>
12 years, 7 months
Hibernate SVN: r21058 - core/patches.
by hibernate-commits@lists.jboss.org
Author: brmeyer
Date: 2012-08-30 12:35:53 -0400 (Thu, 30 Aug 2012)
New Revision: 21058
Added:
core/patches/JBPAPP-7103/
Log:
Branching for JBPAPP-7103
12 years, 7 months
Hibernate SVN: r21057 - annotations/patches/JBPAPP-7103.
by hibernate-commits@lists.jboss.org
Author: brmeyer
Date: 2012-08-30 12:32:34 -0400 (Thu, 30 Aug 2012)
New Revision: 21057
Added:
annotations/patches/JBPAPP-7103/lgpl.txt
annotations/patches/JBPAPP-7103/pom.xml
annotations/patches/JBPAPP-7103/src/
Log:
Branching for JBPAPP-7103
Copied: annotations/patches/JBPAPP-7103/lgpl.txt (from rev 21056, annotations/branches/v3_4_0_GA_CP/lgpl.txt)
===================================================================
--- annotations/patches/JBPAPP-7103/lgpl.txt (rev 0)
+++ annotations/patches/JBPAPP-7103/lgpl.txt 2012-08-30 16:32:34 UTC (rev 21057)
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
Copied: annotations/patches/JBPAPP-7103/pom.xml (from rev 21056, annotations/branches/v3_4_0_GA_CP/pom.xml)
===================================================================
--- annotations/patches/JBPAPP-7103/pom.xml (rev 0)
+++ annotations/patches/JBPAPP-7103/pom.xml 2012-08-30 16:32:34 UTC (rev 21057)
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2011, Red Hat Inc. or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Inc.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ ~
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.2.GA_CP05</version>
+ </parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <packaging>jar</packaging>
+ <version>3.4.0.GA_CP05</version>
+
+ <name>Hibernate Annotations</name>
+ <description>Annotations metadata for Hibernate</description>
+ <url>http://annotations.hibernate.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>3.3.2.GA_CP05</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>ejb3-persistence</artifactId>
+ <version>1.0.2.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-commons-annotations</artifactId>
+ <version>3.1.0.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>3.3.2.GA_CP05</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-injection-plugin</artifactId>
+ <version>1.0.2</version>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>bytecode</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <bytecodeInjections>
+ <bytecodeInjection>
+ <expression>${pom.version}</expression>
+ <targetMembers>
+ <constant>
+ <className>org.hibernate.cfg.annotations.Version</className>
+ <fieldName>VERSION</fieldName>
+ </constant>
+ <methodBodyReturn>
+ <className>org.hibernate.cfg.annotations.Version</className>
+ <methodName>getVersionString</methodName>
+ </methodBodyReturn>
+ </targetMembers>
+ </bytecodeInjection>
+ </bytecodeInjections>
+ </configuration>
+ </plugin>
+
+ <!-- add specification/implementation details to the manifests -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <addMavenDescriptor>false</addMavenDescriptor>
+ <manifest>
+ <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ <manifestEntries>
+ <Specification-Vendor>jcp.org</Specification-Vendor>
+ <Specification-Version>1.0</Specification-Version>
+ <Specification-Title>Java Persistence</Specification-Title>
+ <Implementation-Vendor-Id>hibernate.org</Implementation-Vendor-Id>
+ <Implementation-URL>http://annotations.hibernate.org</Implementation-URL>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/dist.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <links>
+ <link>http://download.oracle.com/javase/6/docs/api/</link>
+ <link>http://download.oracle.com/javaee/6/api/</link>
+ </links>
+ <stylesheetfile>${basedir}/src/main/javadoc/jdstyle.css</stylesheetfile>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
12 years, 7 months
Hibernate SVN: r21056 - annotations/patches.
by hibernate-commits@lists.jboss.org
Author: brmeyer
Date: 2012-08-30 12:30:45 -0400 (Thu, 30 Aug 2012)
New Revision: 21056
Added:
annotations/patches/JBPAPP-7103/
Log:
Branching for JBPAPP-7103
12 years, 7 months
[hibernate/hibernate-orm] 5e9c82: HHH-7557 - Map entries get deleted
by GitHub
Branch: refs/heads/4.1
Home: https://github.com/hibernate/hibernate-orm
Commit: 5e9c828512cb97f74f287a8184b734b7ef6bd431
https://github.com/hibernate/hibernate-orm/commit/5e9c828512cb97f74f287a8...
Author: Steve Ebersole <steve(a)hibernate.org>
Date: 2012-08-30 (Thu, 30 Aug 2012)
Changed paths:
M hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java
A hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/EntityMapTest.java
A hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapHolder.java
A hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapKey.java
A hibernate-core/src/test/java/org/hibernate/test/collection/map/hhh7557/MapValue.java
Log Message:
-----------
HHH-7557 - Map entries get deleted
(cherry picked from commit 45f6414f92c9cec920fd84adfd92e1e2347366d0)
12 years, 7 months