From: Vance K. <va...@us...> - 2006-02-01 08:41:10
|
User: vancek Date: 06/02/01 00:41:04 Modified: andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3AssociationEndFacadeLogicImpl.java Log: getFetchType now checked for compositionDefinesEagerLoading if no fetch type tagged value exists. Revision Changes Path 1.6 +36 -16 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3AssociationEndFacadeLogicImpl.java Index: EJB3AssociationEndFacadeLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3AssociationEndFacadeLogicImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -r1.5 -r1.6 --- EJB3AssociationEndFacadeLogicImpl.java 28 Jan 2006 02:57:44 -0000 1.5 +++ EJB3AssociationEndFacadeLogicImpl.java 1 Feb 2006 08:41:04 -0000 1.6 @@ -139,6 +139,12 @@ collectionTypes.add(COLLECTION_TYPE_COLLECTION); } + /** + * Stores the property indicating whether or not composition should define + * the eager loading strategy and aggregation define lazy loading strategy. + */ + private static final String COMPOSITION_DEFINES_EAGER_LOADING = "compositionDefinesEagerLoading"; + // ---------------- constructor ------------------------------- public EJB3AssociationEndFacadeLogicImpl (Object metaObject, String context) @@ -246,14 +252,6 @@ /** * @see org.andromda.cartridges.ejb3.metafacades.EJB3AssociationEndFacade#getFetchType() - * - * This method is always called on the target association end. - * If a fetch type tagged value is not found on the target end, then compare the association - * relationship from the source end to indicate the default fetch types. - * <ul> - * <li>One-2-Many and Many-2-Many defaults to LAZY loading</li> - * <li>Many-2-One and One-2-One default to EAGER loading</li> - * </ul> */ protected String handleGetFetchType() { @@ -261,6 +259,29 @@ if (StringUtils.isBlank(fetchType)) { + // check whether or not composition defines eager loading is turned on + boolean compositionDefinesEagerLoading = + Boolean.valueOf(String.valueOf(this.getConfiguredProperty(COMPOSITION_DEFINES_EAGER_LOADING))) + .booleanValue(); + + if (compositionDefinesEagerLoading) + { + if (this.getOtherEnd().isComposition()) + { + fetchType = EJB3Globals.FETCH_TYPE_EAGER; + } + else if (this.getOtherEnd().isAggregation()) + { + fetchType = EJB3Globals.FETCH_TYPE_LAZY; + } + } + } + + /** + * Go for defaults if blank + */ + if (StringUtils.isBlank(fetchType)) + { if (this.getOtherEnd().isOne2Many() || this.getOtherEnd().isMany2Many()) { fetchType = EJB3Globals.FETCH_TYPE_LAZY; @@ -270,7 +291,6 @@ fetchType = EJB3Globals.FETCH_TYPE_EAGER; } } - return fetchType; } |