KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > loader > entity > EntityJoinWalker


1 //$Id: EntityJoinWalker.java,v 1.2 2005/06/13 20:27:16 oneovthafew Exp $
2
package org.hibernate.loader.entity;
3
4 import java.util.Collections JavaDoc;
5 import java.util.Map JavaDoc;
6
7 import org.hibernate.FetchMode;
8 import org.hibernate.LockMode;
9 import org.hibernate.MappingException;
10 import org.hibernate.engine.SessionFactoryImplementor;
11 import org.hibernate.loader.AbstractEntityJoinWalker;
12 import org.hibernate.persister.entity.OuterJoinLoadable;
13 import org.hibernate.type.AssociationType;
14
15 /**
16  * A walker for loaders that fetch entities
17  *
18  * @see EntityLoader
19  * @author Gavin King
20  */

21 public class EntityJoinWalker extends AbstractEntityJoinWalker {
22     
23     private final LockMode lockMode;
24
25     public EntityJoinWalker(
26             OuterJoinLoadable persister,
27             String JavaDoc[] uniqueKey,
28             int batchSize,
29             LockMode lockMode,
30             SessionFactoryImplementor factory,
31             Map JavaDoc enabledFilters)
32     throws MappingException {
33         super(persister, factory, enabledFilters);
34
35         this.lockMode = lockMode;
36         
37         StringBuffer JavaDoc whereCondition = whereString( getAlias(), uniqueKey, batchSize )
38             //include the discriminator and class-level where, but not filters
39
.append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );
40
41         initAll( whereCondition.toString(), "", lockMode );
42         
43     }
44
45     /**
46      * Disable outer join fetching if this loader obtains an
47      * upgrade lock mode
48      */

49     protected boolean isJoinedFetchEnabled(AssociationType type, FetchMode config) {
50         return lockMode.greaterThan(LockMode.READ) ?
51             false :
52             super.isJoinedFetchEnabled(type, config);
53     }
54
55     public String JavaDoc getComment() {
56         return "load " + getPersister().getEntityName();
57     }
58     
59 }
Popular Tags