| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Hibernate
Revision: 15091
Author: steve.ebersole@jboss.com
Date: 15 Aug 2008 17:20:15
Changes:HHH-3414 : fetch profiles, phase 1 : join fetching
Files:| ... | ...@@ -42,6 +42,7 @@ | |
| 42 | 42 | import org.hibernate.engine.SessionFactoryImplementor; |
| 43 | 43 | import org.hibernate.engine.SessionImplementor; |
| 44 | 44 | import org.hibernate.engine.SubselectFetch; |
| 45 | import org.hibernate.engine.LoadQueryInfluencers; | |
| 45 | 46 | import org.hibernate.exception.JDBCExceptionHelper; |
| 46 | 47 | import org.hibernate.loader.collection.BatchingCollectionInitializer; |
| 47 | 48 | import org.hibernate.loader.collection.CollectionInitializer; |
| ... | ...@@ -315,9 +316,9 @@ | |
| 315 | 316 | * |
| 316 | 317 | * @see org.hibernate.loader.collection.BasicCollectionLoader |
| 317 | 318 | */ |
| 318 | protected CollectionInitializer createCollectionInitializer(java.util.Map enabledFilters) | |
| 319 | protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers) | |
| 319 | 320 | throws MappingException { |
| 320 | return BatchingCollectionInitializer.createBatchingCollectionInitializer( this, batchSize, getFactory(), enabledFilters ); | |
| 321 | return BatchingCollectionInitializer.createBatchingCollectionInitializer( this, batchSize, getFactory(), loadQueryInfluencers ); | |
| 321 | 322 | } |
| 322 | 323 | |
| 323 | 324 | public String fromJoinFragment(String alias, boolean innerJoin, boolean includeSubclasses) { |
| ... | ...@@ -336,8 +337,8 @@ | |
| 336 | 337 | subselect.getQueryParameters(), |
| 337 | 338 | subselect.getNamedParameterLocMap(), |
| 338 | 339 | session.getFactory(), |
| 339 | session.getEnabledFilters() | |
| 340 | ); | |
| 340 | session.getLoadQueryInfluencers() | |
| 341 | ); | |
| 341 | 342 | } |
| 342 | 343 | |
| 343 | 344 | } |
| ... | ...@@ -22,6 +22,7 @@ | |
| 22 | 22 | |
| 23 | 23 | hibernate.connection.pool_size 5 |
| 24 | 24 | |
| 25 | hibernate.show_sql true | |
| 25 | 26 | hibernate.format_sql true |
| 26 | 27 | |
| 27 | 28 | hibernate.max_fetch_depth 5 |
| ... | ...@@ -35,6 +35,7 @@ | |
| 35 | 35 | import org.hibernate.engine.QueryParameters; |
| 36 | 36 | import org.hibernate.engine.SessionFactoryImplementor; |
| 37 | 37 | import org.hibernate.engine.SessionImplementor; |
| 38 | import org.hibernate.engine.LoadQueryInfluencers; | |
| 38 | 39 | import org.hibernate.persister.collection.QueryableCollection; |
| 39 | 40 | import org.hibernate.type.Type; |
| 40 | 41 | |
| ... | ...@@ -57,10 +58,8 @@ | |
| 57 | 58 | QueryParameters queryParameters, |
| 58 | 59 | Map namedParameterLocMap, |
| 59 | 60 | SessionFactoryImplementor factory, |
| 60 | Map enabledFilters) | |
| 61 | throws MappingException { | |
| 62 | ||
| 63 | super(persister, 1, subquery, factory, enabledFilters); | |
| 61 | LoadQueryInfluencers loadQueryInfluencers) throws MappingException { | |
| 62 | super( persister, 1, subquery, factory, loadQueryInfluencers ); | |
| 64 | 63 | |
| 65 | 64 | keys = new Serializable[ entityKeys.size() ]; |
| 66 | 65 | Iterator iter = entityKeys.iterator(); |
| ... | ...@@ -73,11 +72,9 @@ | |
| 73 | 72 | this.types = queryParameters.getFilteredPositionalParameterTypes(); |
| 74 | 73 | this.values = queryParameters.getFilteredPositionalParameterValues(); |
| 75 | 74 | this.namedParameterLocMap = namedParameterLocMap; |
| 76 | ||
| 77 | 75 | } |
| 78 | 76 | |
| 79 | public void initialize(Serializable id, SessionImplementor session) | |
| 80 | throws HibernateException { | |
| 77 | public void initialize(Serializable id, SessionImplementor session) throws HibernateException { | |
| 81 | 78 | loadCollectionSubselect( |
| 82 | 79 | session, |
| 83 | 80 | keys, |
| ... | ...@@ -85,7 +82,7 @@ | |
| 85 | 82 | types, |
| 86 | 83 | namedParameters, |
| 87 | 84 | getKeyType() |
| 88 | ); | |
| 85 | ); | |
| 89 | 86 | } |
| 90 | 87 | |
| 91 | 88 | public int[] getNamedParameterLocs(String name) { |
| ... | ...@@ -244,4 +244,13 @@ | |
| 244 | 244 | * @throws HibernateException If no filter defined with the given name. |
| 245 | 245 | */ |
| 246 | 246 | public FilterDefinition getFilterDefinition(String filterName) throws HibernateException; |
| 247 | ||
| 248 | /** | |
| 249 | * Determine if this session factory contains a fetch profile definition | |
| 250 | * registered under the given name. | |
| 251 | * | |
| 252 | * @param name The name to check | |
| 253 | * @return True if there is such a fetch profile; false otherwise. | |
| 254 | */ | |
| 255 | public boolean containsFetchProfileDefition(String name); | |
| 247 | 256 | } |
| ... | ...@@ -19,11 +19,12 @@ | |
| 19 | 19 | <!ELEMENT hibernate-mapping ( |
| 20 | 20 | meta*, |
| 21 | 21 | typedef*, |
| 22 | import*, | |
| 22 | import*, | |
| 23 | 23 | (class|subclass|joined-subclass|union-subclass)*, |
| 24 | 24 | resultset*, |
| 25 | 25 | (query|sql-query)*, |
| 26 | 26 | filter-def*, |
| 27 | fetch-profile*, | |
| 27 | 28 | database-object* |
| 28 | 29 | )> |
| 29 | 30 | <!ATTLIST hibernate-mapping schema CDATA #IMPLIED> <!-- default: none --> |
| ... | ...@@ -78,6 +79,7 @@ | |
| 78 | 79 | ((join*,subclass*)|joined-subclass*|union-subclass*), |
| 79 | 80 | loader?,sql-insert?,sql-update?,sql-delete?, |
| 80 | 81 | filter*, |
| 82 | fetch-profile*, | |
| 81 | 83 | resultset*, |
| 82 | 84 | (query|sql-query)* |
| 83 | 85 | )> |
| ... | ...@@ -133,6 +135,22 @@ | |
| 133 | 135 | <!ATTLIST filter name CDATA #REQUIRED> |
| 134 | 136 | <!ATTLIST filter condition CDATA #IMPLIED> |
| 135 | 137 | |
| 138 | <!-- | |
| 139 | --> | |
| 140 | <!ELEMENT fetch-profile (fetch*)> | |
| 141 | <!ATTLIST fetch-profile name CDATA #REQUIRED> | |
| 142 | ||
| 143 | <!-- | |
| 144 | The <fetch> element defines a single path to which the fetch | |
| 145 | refers, as well as the style of fetch to apply. The 'root' of the | |
| 146 | path is different depending upon the context in which the | |
| 147 | containing <fetch-profile/> occurs; within a <class/> element, | |
| 148 | the entity-name of the containing class mapping is assumed... | |
| 149 | --> | |
| 150 | <!ELEMENT fetch EMPTY> | |
| 151 | <!ATTLIST fetch entity CDATA #IMPLIED> <!-- Implied as long as the containing fetch profile is contained in a class mapping --> | |
| 152 | <!ATTLIST fetch association CDATA #REQUIRED> | |
| 153 | <!ATTLIST fetch style (join|select) "join"> | |
| 136 | 154 | |
| 137 | 155 | <!-- A join allows some properties of a class to be persisted to a second table --> |
| 138 | 156 | |
| ... | ...@@ -231,6 +249,7 @@ | |
| 231 | 249 | join*, |
| 232 | 250 | subclass*, |
| 233 | 251 | loader?,sql-insert?,sql-update?,sql-delete?, |
| 252 | fetch-profile*, | |
| 234 | 253 | resultset*, |
| 235 | 254 | (query|sql-query)* |
| 236 | 255 | )> |
| ... | ...@@ -263,6 +282,7 @@ | |
| 263 | 282 | (property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*, |
| 264 | 283 | joined-subclass*, |
| 265 | 284 | loader?,sql-insert?,sql-update?,sql-delete?, |
| 285 | fetch-profile*, | |
| 266 | 286 | resultset*, |
| 267 | 287 | (query|sql-query)* |
| 268 | 288 | )> |
| ... | ...@@ -298,6 +318,7 @@ | |
| 298 | 318 | (property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*, |
| 299 | 319 | union-subclass*, |
| 300 | 320 | loader?,sql-insert?,sql-update?,sql-delete?, |
| 321 | fetch-profile*, | |
| 301 | 322 | resultset*, |
| 302 | 323 | (query|sql-query)* |
| 303 | 324 | )> |
| ... | ...@@ -46,6 +46,7 @@ | |
| 46 | 46 | import org.hibernate.mapping.TypeDef; |
| 47 | 47 | import org.hibernate.mapping.AuxiliaryDatabaseObject; |
| 48 | 48 | import org.hibernate.mapping.Column; |
| 49 | import org.hibernate.mapping.FetchProfile; | |
| 49 | 50 | import org.hibernate.util.StringHelper; |
| 50 | 51 | |
| 51 | 52 | /** |
| ... | ...@@ -77,6 +78,7 @@ | |
| 77 | 78 | protected final List propertyReferences; |
| 78 | 79 | protected final NamingStrategy namingStrategy; |
| 79 | 80 | protected final Map filterDefinitions; |
| 81 | protected final Map fetchProfiles; | |
| 80 | 82 | protected final List auxiliaryDatabaseObjects; |
| 81 | 83 | |
| 82 | 84 | protected final Map extendsQueue; |
| ... | ...@@ -111,12 +113,12 @@ | |
| 111 | 113 | final NamingStrategy namingStrategy, |
| 112 | 114 | final Map typeDefs, |
| 113 | 115 | final Map filterDefinitions, |
| 116 | final Map fetchProfiles, | |
| 114 | 117 | // final List extendsQueue, |
| 115 | 118 | final Map extendsQueue, |
| 116 | 119 | final List auxiliaryDatabaseObjects, |
| 117 | 120 | final Map tableNamebinding, |
| 118 | final Map columnNameBindingPerTable | |
| 119 | ) { | |
| 121 | final Map columnNameBindingPerTable) { | |
| 120 | 122 | this.classes = classes; |
| 121 | 123 | this.collections = collections; |
| 122 | 124 | this.queries = queries; |
| ... | ...@@ -129,6 +131,7 @@ | |
| 129 | 131 | this.namingStrategy = namingStrategy; |
| 130 | 132 | this.typeDefs = typeDefs; |
| 131 | 133 | this.filterDefinitions = filterDefinitions; |
| 134 | this.fetchProfiles = fetchProfiles; | |
| 132 | 135 | this.extendsQueue = extendsQueue; |
| 133 | 136 | this.auxiliaryDatabaseObjects = auxiliaryDatabaseObjects; |
| 134 | 137 | this.tableNameBinding = tableNamebinding; |
| ... | ...@@ -418,7 +421,20 @@ | |
| 418 | 421 | public FilterDefinition getFilterDefinition(String name) { |
| 419 | 422 | return (FilterDefinition) filterDefinitions.get(name); |
| 420 | 423 | } |
| 421 | ||
| 424 | ||
| 425 | public Map getFetchProfiles() { | |
| 426 | return fetchProfiles; | |
| 427 | } | |
| 428 | ||
| 429 | public FetchProfile findOrCreateFetchProfile(String name) { | |
| 430 | FetchProfile profile = ( FetchProfile ) fetchProfiles.get( name ); | |
| 431 | if ( profile == null ) { | |
| 432 | profile = new FetchProfile( name ); | |
| 433 | fetchProfiles.put( name, profile ); | |
| 434 | } | |
| 435 | return profile; | |
| 436 | } | |
| 437 | ||
| 422 | 438 | public boolean isDefaultLazy() { |
| 423 | 439 | return defaultLazy; |
| 424 | 440 | } |
| ... | ...@@ -198,4 +198,8 @@ | |
| 198 | 198 | public FilterDefinition getFilterDefinition(String filterName) throws HibernateException { |
| 199 | 199 | return getImpl().getFilterDefinition( filterName ); |
| 200 | 200 | } |
| 201 | ||
| 202 | public boolean containsFetchProfileDefition(String name) { | |
| 203 | return getImpl().containsFetchProfileDefition( name ); | |
| 204 | } | |
| 201 | 205 | } |
| ... | ...@@ -0,0 +1,58 @@ | |
| 1 | /* | |
| 2 | * Hibernate, Relational Persistence for Idiomatic Java | |
| 3 | * | |
| 4 | * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as | |
| 5 | * indicated by the @author tags or express copyright attribution | |
| 6 | * statements applied by the authors. All third-party contributions are | |
| 7 | * distributed under license by Red Hat Middleware LLC. | |
| 8 | * | |
| 9 | * This copyrighted material is made available to anyone wishing to use, modify, | |
| 10 | * copy, or redistribute it subject to the terms and conditions of the GNU | |
| 11 | * Lesser General Public License, as published by the Free Software Foundation. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
| 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
| 16 | * for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU Lesser General Public License | |
| 19 | * along with this distribution; if not, write to: | |
| 20 | * Free Software Foundation, Inc. | |
| 21 | * 51 Franklin Street, Fifth Floor | |
| 22 | * Boston, MA 02110-1301 USA | |
| 23 | * | |
| 24 | */ | |
| 25 | package org.hibernate.test.fetchprofiles.basic; | |
| 26 | ||
| 27 | /** | |
| 28 | * TODO : javadoc | |
| 29 | * | |
| 30 | * @author Steve Ebersole | |
| 31 | */ | |
| 32 | public class Student { | |
| 33 | private Long id; | |
| 34 | private String name; | |
| 35 | ||
| 36 | public Student() { | |
| 37 | } | |
| 38 | ||
| 39 | public Student(String name) { | |
| 40 | this.name = name; | |
| 41 | } | |
| 42 | ||
| 43 | public Long getId() { | |
| 44 | return id; | |
| 45 | } | |
| 46 | ||
| 47 | public void setId(Long id) { | |
| 48 | this.id = id; | |
| 49 | } | |
| 50 | ||
| 51 | public String getName() { | |
| 52 | return name; | |
| 53 | } | |
| 54 | ||
| 55 | public void setName(String name) { | |
| 56 | this.name = name; | |
| 57 | } | |
| 58 | } |
| ... | ...@@ -0,0 +1,56 @@ | |
| 1 | /* | |
| 2 | * Hibernate, Relational Persistence for Idiomatic Java | |
| 3 | * | |
| 4 | * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as | |
| 5 | * indicated by the @author tags or express copyright attribution | |
| 6 | * statements applied by the authors. All third-party contributions are | |
| 7 | * distributed under license by Red Hat Middleware LLC. | |
| 8 | * | |
| 9 | * This copyrighted material is made available to anyone wishing to use, modify, | |
| 10 | * copy, or redistribute it subject to the terms and conditions of the GNU | |
| 11 | * Lesser General Public License, as published by the Free Software Foundation. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
| 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
| 16 | * for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU Lesser General Public License | |
| 19 | * along with this distribution; if not, write to: | |
| 20 | * Free Software Foundation, Inc. | |
| 21 | * 51 Franklin Street, Fifth Floor | |
| 22 | * Boston, MA 02110-1301 USA | |
| 23 | * | |
| 24 | */ | |
| 25 | package org.hibernate.engine.profile; | |
| 26 | ||
| 27 | import org.hibernate.persister.entity.EntityPersister; | |
| 28 | ||
| 29 | /** | |
| 30 | * Models the association of a given fetch. | |
| 31 | * | |
| 32 | * @author Steve Ebersole | |
| 33 | */ | |
| 34 | public class Association { | |
| 35 | private final EntityPersister owner; | |
| 36 | private final String associationPath; | |
| 37 | private final String role; | |
| 38 | ||
| 39 | public Association(EntityPersister owner, String associationPath) { | |
| 40 | this.owner = owner; | |
| 41 | this.associationPath = associationPath; | |
| 42 | this.role = owner.getEntityName() + '.' + associationPath; | |
| 43 | } | |
| 44 | ||
| 45 | public EntityPersister getOwner() { | |
| 46 | return owner; | |
| 47 | } | |
| 48 | ||
| 49 | public String getAssociationPath() { | |
| 50 | return associationPath; | |
| 51 | } | |
| 52 | ||
| 53 | public String getRole() { | |
| 54 | return role; | |
| 55 | } | |
| 56 | } |
| ... | ...@@ -25,11 +25,11 @@ | |
| 25 | 25 | package org.hibernate.loader.collection; |
| 26 | 26 | |
| 27 | 27 | import java.io.Serializable; |
| 28 | import java.util.Map; | |
| 29 | 28 | |
| 30 | 29 | import org.hibernate.HibernateException; |
| 31 | 30 | import org.hibernate.engine.SessionFactoryImplementor; |
| 32 | 31 | import org.hibernate.engine.SessionImplementor; |
| 32 | import org.hibernate.engine.LoadQueryInfluencers; | |
| 33 | 33 | import org.hibernate.loader.OuterJoinLoader; |
| 34 | 34 | import org.hibernate.persister.collection.QueryableCollection; |
| 35 | 35 | import org.hibernate.type.Type; |
| ... | ...@@ -45,8 +45,11 @@ | |
| 45 | 45 | |
| 46 | 46 | private final QueryableCollection collectionPersister; |
| 47 | 47 | |
| 48 | public CollectionLoader(QueryableCollection collectionPersister, SessionFactoryImplementor factory, Map enabledFilters) { | |
| 49 | super( factory, enabledFilters ); | |
| 48 | public CollectionLoader( | |
| 49 | QueryableCollection collectionPersister, | |
| 50 | SessionFactoryImplementor factory, | |
| 51 | LoadQueryInfluencers loadQueryInfluencers) { | |
| 52 | super( factory, loadQueryInfluencers ); | |
| 50 | 53 | this.collectionPersister = collectionPersister; |
| 51 | 54 | } |
| 52 | 55 |
| ... | ...@@ -813,4 +813,40 @@ | |
| 813 | 813 | * @see #disconnect() |
| 814 | 814 | */ |
| 815 | 815 | void reconnect(Connection connection) throws HibernateException; |
| 816 | ||
| 817 | /** | |
| 818 | * Is a particular fetch profile enabled on this session? | |
| 819 | * | |
| 820 | * @param name The name of the profile to be checked. | |
| 821 | * @return True if fetch profile is enabled; false if not. | |
| 822 | * @throws UnknownProfileException Indicates that the given name does not | |
| 823 | * match any known profile names | |
| 824 | * | |
| 825 | * @see org.hibernate.engine.profile.FetchProfile for discussion of this feature | |
| 826 | */ | |
| 827 | public boolean isFetchProfileEnabled(String name) throws UnknownProfileException; | |
| 828 | ||
| 829 | /** | |
| 830 | * Enable a particular fetch profile on this session. No-op if requested | |
| 831 | * profile is already enabled. | |
| 832 | * | |
| 833 | * @param name The name of the fetch profile to be enabled. | |
| 834 | * @throws UnknownProfileException Indicates that the given name does not | |
| 835 | * match any known profile names | |
| 836 | * | |
| 837 | * @see org.hibernate.engine.profile.FetchProfile for discussion of this feature | |
| 838 | */ | |
| 839 | public void enableFetchProfile(String name) throws UnknownProfileException; | |
| 840 | ||
| 841 | /** | |
| 842 | * Disable a particular fetch profile on this session. No-op if requested | |
| 843 | * profile is already disabled. | |
| 844 | * | |
| 845 | * @param name The name of the fetch profile to be disabled. | |
| 846 | * @throws UnknownProfileException Indicates that the given name does not | |
| 847 | * match any known profile names | |
| 848 | * | |
| 849 | * @see org.hibernate.engine.profile.FetchProfile for discussion of this feature | |
| 850 | */ | |
| 851 | public void disableFetchProfile(String name) throws UnknownProfileException; | |
| 816 | 852 | } |
| ... | ...@@ -24,12 +24,11 @@ | |
| 24 | 24 | */ |
| 25 | 25 | package org.hibernate.loader.collection; |
| 26 | 26 | |
| 27 | import java.util.Map; | |
| 28 | ||
| 29 | 27 | import org.slf4j.Logger; |
| 30 | 28 | import org.slf4j.LoggerFactory; |
| 31 | 29 | import org.hibernate.MappingException; |
| 32 | 30 | import org.hibernate.engine.SessionFactoryImplementor; |
| 31 | import org.hibernate.engine.LoadQueryInfluencers; | |
| 33 | 32 | import org.hibernate.loader.JoinWalker; |
| 34 | 33 | import org.hibernate.persister.collection.QueryableCollection; |
| 35 | 34 | |
| ... | ...@@ -49,18 +48,16 @@ | |
| 49 | 48 | public BasicCollectionLoader( |
| 50 | 49 | QueryableCollection collectionPersister, |
| 51 | 50 | SessionFactoryImplementor session, |
| 52 | Map enabledFilters) | |
| 53 | throws MappingException { | |
| 54 | this(collectionPersister, 1, session, enabledFilters); | |
| 51 | LoadQueryInfluencers loadQueryInfluencers) throws MappingException { | |
| 52 | this( collectionPersister, 1, session, loadQueryInfluencers ); | |
| 55 | 53 | } |
| 56 | 54 | |
| 57 | 55 | public BasicCollectionLoader( |
| 58 | 56 | QueryableCollection collectionPersister, |
| 59 | 57 | int batchSize, |
| 60 | 58 | SessionFactoryImplementor factory, |
| 61 | Map enabledFilters) | |
| 62 | throws MappingException { | |
| 63 | this(collectionPersister, batchSize, null, factory, enabledFilters); | |
| 59 | LoadQueryInfluencers loadQueryInfluencers) throws MappingException { | |
| 60 | this( collectionPersister, batchSize, null, factory, loadQueryInfluencers ); | |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | 63 | protected BasicCollectionLoader( |
| ... | ...@@ -68,18 +65,16 @@ | |
| 68 | 65 | int batchSize, |
| 69 | 66 | String subquery, |
| 70 | 67 | SessionFactoryImplementor factory, |
| 71 | Map enabledFilters) | |
| 72 | throws MappingException { | |
| 73 | ||
| 74 | super(collectionPersister, factory, enabledFilters); | |
| 68 | LoadQueryInfluencers loadQueryInfluencers) throws MappingException { | |
| 69 | super( collectionPersister, factory, loadQueryInfluencers ); | |
| 75 | 70 | |
| 76 | 71 | JoinWalker walker = new BasicCollectionJoinWalker( |
| 77 | 72 | collectionPersister, |
| 78 | 73 | batchSize, |
| 79 | 74 | subquery, |
| 80 | 75 | factory, |
| 81 | enabledFilters | |
| 82 | ); | |
| 76 | loadQueryInfluencers | |
| 77 | ); | |
| 83 | 78 | initFromWalker( walker ); |
| 84 | 79 | |
| 85 | 80 | postInstantiate(); |
| ... | ...@@ -25,12 +25,14 @@ | |
| 25 | 25 | package org.hibernate.loader.entity; |
| 26 | 26 | |
| 27 | 27 | import java.util.Map; |
| 28 | import java.util.Set; | |
| 28 | 29 | |
| 29 | 30 | import org.hibernate.HibernateException; |
| 30 | 31 | import org.hibernate.LockMode; |
| 31 | 32 | import org.hibernate.MappingException; |
| 32 | 33 | import org.hibernate.engine.SessionFactoryImplementor; |
| 33 | 34 | import org.hibernate.engine.SessionImplementor; |
| 35 | import org.hibernate.engine.LoadQueryInfluencers; | |
| 34 | 36 | import org.hibernate.loader.JoinWalker; |
| 35 | 37 | import org.hibernate.persister.entity.OuterJoinLoadable; |
| 36 | 38 | import org.hibernate.type.Type; |
| ... | ...@@ -51,9 +53,8 @@ | |
| 51 | 53 | OuterJoinLoadable persister, |
| 52 | 54 | LockMode lockMode, |
| 53 | 55 | SessionFactoryImplementor factory, |
| 54 | Map enabledFilters) | |
| 55 | throws MappingException { | |
| 56 | this(persister, 1, lockMode, factory, enabledFilters); | |
| 56 | LoadQueryInfluencers loadQueryInfluencers) throws MappingException { | |
| 57 | this( persister, 1, lockMode, factory, loadQueryInfluencers ); | |
| 57 | 58 | } |
| 58 | 59 | |
| 59 | 60 | public EntityLoader( |
| ... | ...@@ -61,16 +62,15 @@ | |
| 61 | 62 | int batchSize, |
| 62 | 63 | LockMode lockMode, |
| 63 | 64 | SessionFactoryImplementor factory, |
| 64 | Map enabledFilters) | |
| 65 | throws MappingException { | |
| 66 | this( | |
| 67 | persister, | |
| 65 | LoadQueryInfluencers loadQueryInfluencers) throws MappingException { | |
| 66 | this( | |
| 67 | persister, | |
| 68 | 68 | persister.getIdentifierColumnNames(), |
| 69 | 69 | persister.getIdentifierType(), |
| 70 | 70 | batchSize, |
| 71 | 71 | lockMode, |
| 72 | 72 | factory, |
| 73 | enabledFilters | |
| 73 | loadQueryInfluencers | |
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | |
| ... | ...@@ -81,9 +81,8 @@ | |
| 81 | 81 | int batchSize, |
| 82 | 82 | LockMode lockMode, |
| 83 | 83 | SessionFactoryImplementor factory, |
| 84 | Map enabledFilters) | |
| 85 | throws MappingException { | |
| 86 | super(persister, uniqueKeyType, factory, enabledFilters); | |
| 84 | LoadQueryInfluencers loadQueryInfluencers) throws MappingException { | |
| 85 | super( persister, uniqueKeyType, factory, loadQueryInfluencers ); | |
| 87 | 86 | |
| 88 | 87 | JoinWalker walker = new EntityJoinWalker( |
| 89 | 88 | persister, |
| ... | ...@@ -91,8 +90,8 @@ | |
| 91 | 90 | batchSize, |
| 92 | 91 | lockMode, |
| 93 | 92 | factory, |
| 94 | enabledFilters | |
| 95 | ); | |
| 93 | loadQueryInfluencers | |
| 94 | ); | |
| 96 | 95 | initFromWalker( walker ); |
| 97 | 96 | |
| 98 | 97 | postInstantiate(); |
| ... | ...@@ -103,9 +102,10 @@ | |
| 103 | 102 | |
| 104 | 103 | } |
| 105 | 104 | |
| 106 | public Object loadByUniqueKey(SessionImplementor session, Object key) | |
| 107 | throws HibernateException { | |
| 108 | return load(session, key, null, null); | |
| 105 | public Object loadByUniqueKey( | |
| 106 | SessionImplementor session, | |
| 107 | Object key) throws HibernateException { | |
| 108 | return load( session, key, null, null ); | |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | protected boolean isSingleRowLoader() { |
| ... | ...@@ -40,6 +40,7 @@ | |
| 40 | 40 | import org.hibernate.engine.SessionFactoryImplementor; |
| 41 | 41 | import org.hibernate.engine.SessionImplementor; |
| 42 | 42 | import org.hibernate.engine.SubselectFetch; |
| 43 | import org.hibernate.engine.LoadQueryInfluencers; | |
| 43 | 44 | import org.hibernate.exception.JDBCExceptionHelper; |
| 44 | 45 | import org.hibernate.loader.collection.BatchingCollectionInitializer; |
| 45 | 46 | import org.hibernate.loader.collection.CollectionInitializer; |
| ... | ...@@ -338,8 +339,9 @@ | |
| 338 | 339 | * |
| 339 | 340 | * @see org.hibernate.loader.collection.OneToManyLoader |
| 340 | 341 | */ |
| 341 | protected CollectionInitializer createCollectionInitializer(java.util.Map enabledFilters) throws MappingException { | |
| 342 | return BatchingCollectionInitializer.createBatchingOneToManyInitializer( this, batchSize, getFactory(), enabledFilters ); | |
| 342 | protected CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers) | |
| 343 | throws MappingException { | |
| 344 | return BatchingCollectionInitializer.createBatchingOneToManyInitializer( this, batchSize, getFactory(), loadQueryInfluencers ); | |
| 343 | 345 | } |
| 344 | 346 | |
| 345 | 347 | public String fromJoinFragment(String alias, |
| ... | ...@@ -375,12 +377,12 @@ | |
| 375 | 377 | subselect.getQueryParameters(), |
| 376 | 378 | subselect.getNamedParameterLocMap(), |
| 377 | 379 | session.getFactory(), |
| 378 | session.getEnabledFilters() | |
| 380 | session.getLoadQueryInfluencers() | |
| 379 | 381 | ); |
| 380 | 382 | } |
| 381 | 383 | |
| 382 | 384 | public Object getElementByIndex(Serializable key, Object index, SessionImplementor session, Object owner) { |
| 383 | return new CollectionElementLoader( this, getFactory(), session.getEnabledFilters() ) | |
| 385 | return new CollectionElementLoader( this, getFactory(), session.getLoadQueryInfluencers() ) | |
| 384 | 386 | .loadElement( session, key, incrementIndexByBase(index) ); |
| 385 | 387 | } |
| 386 | 388 |
| ... | ...@@ -30,6 +30,7 @@ | |
| 30 | 30 | import org.hibernate.engine.CascadeStyle; |
| 31 | 31 | import org.hibernate.engine.CascadingAction; |
| 32 | 32 | import org.hibernate.engine.SessionFactoryImplementor; |
| 33 | import org.hibernate.engine.LoadQueryInfluencers; | |
| 33 | 34 | import org.hibernate.loader.AbstractEntityJoinWalker; |
| 34 | 35 | import org.hibernate.persister.entity.OuterJoinLoadable; |
| 35 | 36 | import org.hibernate.type.AssociationType; |
| ... | ...@@ -41,7 +42,7 @@ | |
| 41 | 42 | |
| 42 | 43 | public CascadeEntityJoinWalker(OuterJoinLoadable persister, CascadingAction action, SessionFactoryImplementor factory) |
| 43 | 44 | throws MappingException { |
| 44 | super( persister, factory, CollectionHelper.EMPTY_MAP ); | |
| 45 | super( persister, factory, LoadQueryInfluencers.NONE ); | |
| 45 | 46 | this.cascadeAction = action; |
| 46 | 47 | StringBuffer whereCondition = whereString( getAlias(), persister.getIdentifierColumnNames(), 1 ) |
| 47 | 48 | //include the discriminator and class-level where, but not filters |
| ... | ...@@ -0,0 +1,123 @@ | |
| 1 | /* | |
| 2 | * Hibernate, Relational Persistence for Idiomatic Java | |
| 3 | * | |
| 4 | * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as | |
| 5 | * indicated by the @author tags or express copyright attribution | |
| 6 | * statements applied by the authors. All third-party contributions are | |
| 7 | * distributed under license by Red Hat Middleware LLC. | |
| 8 | * | |
| 9 | * This copyrighted material is made available to anyone wishing to use, modify, | |
| 10 | * copy, or redistribute it subject to the terms and conditions of the GNU | |
| 11 | * Lesser General Public License, as published by the Free Software Foundation. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
| 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
| 16 | * for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU Lesser General Public License | |
| 19 | * along with this distribution; if not, write to: | |
| 20 | * Free Software Foundation, Inc. | |
| 21 | * 51 Franklin Street, Fifth Floor | |
| 22 | * Boston, MA 02110-1301 USA | |
| 23 | * | |
| 24 | */ | |
| 25 | package org.hibernate.test.fetchprofiles.basic; | |
| 26 | ||
| 27 | /** | |
| 28 | * TODO : javadoc | |
| 29 | * | |
| 30 | * @author Steve Ebersole | |
| 31 | */ | |
| 32 | public class Course { | |
| 33 | private Long id; | |
| 34 | private Code code; | |
| 35 | private String name; | |
| 36 | ||
| 37 | public Course() { | |
| 38 | } | |
| 39 | ||
| 40 | public Course(Code code, String name) { | |
| 41 | this.code = code; | |
| 42 | this.name = name; | |
| 43 | } | |
| 44 | ||
| 45 | public Long getId() { | |
| 46 | return id; | |
| 47 | } | |
| 48 | ||
| 49 | public void setId(Long id) { | |
| 50 | this.id = id; | |
| 51 | } | |
| 52 | ||
| 53 | public Code getCode() { | |
| 54 | return code; | |
| 55 | } | |
| 56 | ||
| 57 | public void setCode(Code code) { | |
| 58 | this.code = code; | |
| 59 | } | |
| 60 | ||
| 61 | public String getName() { | |
| 62 | return name; | |
| 63 | } | |
| 64 | ||
| 65 | public void setName(String name) { | |
| 66 | this.name = name; | |
| 67 | } | |
| 68 | public static class Code { | |
| 69 | private Department department; | |
| 70 | private int number; | |
| 71 | ||
| 72 | public Code() { | |
| 73 | } | |
| 74 | ||
| 75 | public Code(Department department, int number) { | |
| 76 | this.department = department; | |
| 77 | this.number = number; | |
| 78 | } | |
| 79 | ||
| 80 | public Department getDepartment() { | |
| 81 | return department; | |
| 82 | } | |
| 83 | ||
| 84 | public void setDepartment(Department department) { | |
| 85 | this.department = department; | |
| 86 | } | |
| 87 | ||
| 88 | public int getNumber() { | |
| 89 | return number; | |
| 90 | } | |
| 91 | ||
| 92 | public void setNumber(int number) { | |
| 93 | this.number = number; | |
| 94 | } | |
| 95 | ||
| 96 | public boolean equals(Object o) { | |
| 97 | if ( this == o ) { | |
| 98 | return true; | |
| 99 | } | |
| 100 | if ( !( o instanceof Code ) ) { | |
| 101 | return false; | |
| 102 | } | |
| 103 | ||
| 104 | Code code = ( Code ) o; | |
| 105 | ||
| 106 | if ( number != code.number ) { | |
| 107 | return false; | |
| 108 | } | |
| 109 | if ( !department.equals( code.department ) ) { | |
| 110 | return false; | |
| 111 | } | |
| 112 | ||
| 113 | return true; | |
| 114 | } | |
| 115 | ||
| 116 | public int hashCode() { | |
| 117 | int result; | |
| 118 | result = department.hashCode(); | |
| 119 | result = 31 * result + number; | |
| 120 | return result; | |
| 121 | } | |
| 122 | } | |
| 123 | } |
| ... | ...@@ -89,6 +89,7 @@ | |
| 89 | 89 | import org.hibernate.mapping.UnionSubclass; |
| 90 |