HHH-6173 formatting

This commit is contained in:
Hardy Ferentschik 2011-06-24 16:48:10 +02:00
parent 157d50b434
commit d86ce7e68a
3 changed files with 65 additions and 29 deletions

View File

@ -33,9 +33,8 @@ import org.hibernate.internal.util.collections.ArrayHelper;
/** /**
* A contract for defining the aspects of cascading various persistence actions. * A contract for defining the aspects of cascading various persistence actions.
* *
* @see CascadingAction
*
* @author Gavin King * @author Gavin King
* @see CascadingAction
*/ */
public abstract class CascadeStyle implements Serializable { public abstract class CascadeStyle implements Serializable {
@ -43,6 +42,7 @@ public abstract class CascadeStyle implements Serializable {
* For this style, should the given action be cascaded? * For this style, should the given action be cascaded?
* *
* @param action The action to be checked for cascade-ability. * @param action The action to be checked for cascade-ability.
*
* @return True if the action should be cascaded under this style; false otherwise. * @return True if the action should be cascaded under this style; false otherwise.
*/ */
public abstract boolean doCascade(CascadingAction action); public abstract boolean doCascade(CascadingAction action);
@ -57,18 +57,19 @@ public abstract class CascadeStyle implements Serializable {
* control this seperately. * control this seperately.
* *
* @param action The action to be checked for cascade-ability. * @param action The action to be checked for cascade-ability.
*
* @return True if the action should be really cascaded under this style; * @return True if the action should be really cascaded under this style;
* false otherwise. * false otherwise.
*/ */
public boolean reallyDoCascade(CascadingAction action) { public boolean reallyDoCascade(CascadingAction action) {
return doCascade(action); return doCascade( action );
} }
/** /**
* Do we need to delete orphaned collection elements? * Do we need to delete orphaned collection elements?
* *
* @return True if this style need to account for orphan delete * @return True if this style need to account for orphan delete
* operations; false othwerwise. * operations; false othwerwise.
*/ */
public boolean hasOrphanDelete() { public boolean hasOrphanDelete() {
return false; return false;
@ -76,27 +77,38 @@ public abstract class CascadeStyle implements Serializable {
public static final class MultipleCascadeStyle extends CascadeStyle { public static final class MultipleCascadeStyle extends CascadeStyle {
private final CascadeStyle[] styles; private final CascadeStyle[] styles;
public MultipleCascadeStyle(CascadeStyle[] styles) { public MultipleCascadeStyle(CascadeStyle[] styles) {
this.styles = styles; this.styles = styles;
} }
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
for (int i=0; i<styles.length; i++) { for ( CascadeStyle style : styles ) {
if ( styles[i].doCascade(action) ) return true; if ( style.doCascade( action ) ) {
return true;
}
} }
return false; return false;
} }
public boolean reallyDoCascade(CascadingAction action) { public boolean reallyDoCascade(CascadingAction action) {
for (int i=0; i<styles.length; i++) { for ( CascadeStyle style : styles ) {
if ( styles[i].reallyDoCascade(action) ) return true; if ( style.reallyDoCascade( action ) ) {
return true;
}
} }
return false; return false;
} }
public boolean hasOrphanDelete() { public boolean hasOrphanDelete() {
for (int i=0; i<styles.length; i++) { for ( CascadeStyle style : styles ) {
if ( styles[i].hasOrphanDelete() ) return true; if ( style.hasOrphanDelete() ) {
return true;
}
} }
return false; return false;
} }
public String toString() { public String toString() {
return ArrayHelper.toString( styles ); return ArrayHelper.toString( styles );
} }
@ -109,9 +121,11 @@ public abstract class CascadeStyle implements Serializable {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return true; return true;
} }
public boolean hasOrphanDelete() { public boolean hasOrphanDelete() {
return true; return true;
} }
public String toString() { public String toString() {
return "STYLE_ALL_DELETE_ORPHAN"; return "STYLE_ALL_DELETE_ORPHAN";
} }
@ -124,6 +138,7 @@ public abstract class CascadeStyle implements Serializable {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return true; return true;
} }
public String toString() { public String toString() {
return "STYLE_ALL"; return "STYLE_ALL";
} }
@ -134,8 +149,9 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle UPDATE = new CascadeStyle() { public static final CascadeStyle UPDATE = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.SAVE_UPDATE; return action == CascadingAction.SAVE_UPDATE;
} }
public String toString() { public String toString() {
return "STYLE_SAVE_UPDATE"; return "STYLE_SAVE_UPDATE";
} }
@ -146,8 +162,9 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle LOCK = new CascadeStyle() { public static final CascadeStyle LOCK = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.LOCK; return action == CascadingAction.LOCK;
} }
public String toString() { public String toString() {
return "STYLE_LOCK"; return "STYLE_LOCK";
} }
@ -158,8 +175,9 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle REFRESH = new CascadeStyle() { public static final CascadeStyle REFRESH = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.REFRESH; return action == CascadingAction.REFRESH;
} }
public String toString() { public String toString() {
return "STYLE_REFRESH"; return "STYLE_REFRESH";
} }
@ -170,8 +188,9 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle EVICT = new CascadeStyle() { public static final CascadeStyle EVICT = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.EVICT; return action == CascadingAction.EVICT;
} }
public String toString() { public String toString() {
return "STYLE_EVICT"; return "STYLE_EVICT";
} }
@ -182,8 +201,9 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle REPLICATE = new CascadeStyle() { public static final CascadeStyle REPLICATE = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.REPLICATE; return action == CascadingAction.REPLICATE;
} }
public String toString() { public String toString() {
return "STYLE_REPLICATE"; return "STYLE_REPLICATE";
} }
@ -193,8 +213,9 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle MERGE = new CascadeStyle() { public static final CascadeStyle MERGE = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.MERGE; return action == CascadingAction.MERGE;
} }
public String toString() { public String toString() {
return "STYLE_MERGE"; return "STYLE_MERGE";
} }
@ -205,9 +226,10 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle PERSIST = new CascadeStyle() { public static final CascadeStyle PERSIST = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.PERSIST return action == CascadingAction.PERSIST
|| action==CascadingAction.PERSIST_ON_FLUSH; || action == CascadingAction.PERSIST_ON_FLUSH;
} }
public String toString() { public String toString() {
return "STYLE_PERSIST"; return "STYLE_PERSIST";
} }
@ -218,8 +240,9 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle DELETE = new CascadeStyle() { public static final CascadeStyle DELETE = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.DELETE; return action == CascadingAction.DELETE;
} }
public String toString() { public String toString() {
return "STYLE_DELETE"; return "STYLE_DELETE";
} }
@ -230,14 +253,17 @@ public abstract class CascadeStyle implements Serializable {
*/ */
public static final CascadeStyle DELETE_ORPHAN = new CascadeStyle() { public static final CascadeStyle DELETE_ORPHAN = new CascadeStyle() {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return action==CascadingAction.DELETE || action==CascadingAction.SAVE_UPDATE; return action == CascadingAction.DELETE || action == CascadingAction.SAVE_UPDATE;
} }
public boolean reallyDoCascade(CascadingAction action) { public boolean reallyDoCascade(CascadingAction action) {
return action==CascadingAction.DELETE; return action == CascadingAction.DELETE;
} }
public boolean hasOrphanDelete() { public boolean hasOrphanDelete() {
return true; return true;
} }
public String toString() { public String toString() {
return "STYLE_DELETE_ORPHAN"; return "STYLE_DELETE_ORPHAN";
} }
@ -250,6 +276,7 @@ public abstract class CascadeStyle implements Serializable {
public boolean doCascade(CascadingAction action) { public boolean doCascade(CascadingAction action) {
return false; return false;
} }
public String toString() { public String toString() {
return "STYLE_NONE"; return "STYLE_NONE";
} }
@ -258,7 +285,7 @@ public abstract class CascadeStyle implements Serializable {
public CascadeStyle() { public CascadeStyle() {
} }
static final Map STYLES = new HashMap(); static final Map<String, CascadeStyle> STYLES = new HashMap<String, CascadeStyle>();
static { static {
STYLES.put( "all", ALL ); STYLES.put( "all", ALL );
@ -280,12 +307,13 @@ public abstract class CascadeStyle implements Serializable {
* Factory method for obtaining named cascade styles * Factory method for obtaining named cascade styles
* *
* @param cascade The named cascade style name. * @param cascade The named cascade style name.
*
* @return The appropriate CascadeStyle * @return The appropriate CascadeStyle
*/ */
public static CascadeStyle getCascadeStyle(String cascade) { public static CascadeStyle getCascadeStyle(String cascade) {
CascadeStyle style = (CascadeStyle) STYLES.get(cascade); CascadeStyle style = STYLES.get( cascade );
if (style==null) { if ( style == null ) {
throw new MappingException("Unsupported cascade style: " + cascade); throw new MappingException( "Unsupported cascade style: " + cascade );
} }
else { else {
return style; return style;

View File

@ -40,7 +40,6 @@ import org.hibernate.metamodel.relational.TableSpecification;
import org.hibernate.metamodel.source.spi.BindingContext; import org.hibernate.metamodel.source.spi.BindingContext;
import org.hibernate.metamodel.source.spi.MetaAttributeContext; import org.hibernate.metamodel.source.spi.MetaAttributeContext;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.tuple.entity.EntityTuplizer; import org.hibernate.tuple.entity.EntityTuplizer;
/** /**
@ -100,7 +99,11 @@ public class EntityBinding {
public EntityBinding initialize(BindingContext bindingContext, EntityBindingState state) { public EntityBinding initialize(BindingContext bindingContext, EntityBindingState state) {
// todo : Entity will need both entityName and className to be effective // todo : Entity will need both entityName and className to be effective
this.entity = new Entity( state.getEntityName(), state.getSuperType(), bindingContext.makeJavaType( state.getClassName() ) ); this.entity = new Entity(
state.getEntityName(),
state.getSuperType(),
bindingContext.makeJavaType( state.getClassName() )
);
this.isRoot = state.isRoot(); this.isRoot = state.isRoot();
this.entityInheritanceType = state.getEntityInheritanceType(); this.entityInheritanceType = state.getEntityInheritanceType();
@ -242,7 +245,7 @@ public class EntityBinding {
// TODO: fix this after HHH-6337 and HHH-6360 are fixed. for now, just return the identifier binding // TODO: fix this after HHH-6337 and HHH-6360 are fixed. for now, just return the identifier binding
// if this is not a root, then need to include the superclass attribute bindings // if this is not a root, then need to include the superclass attribute bindings
//return getAttributeBindings(); //return getAttributeBindings();
Set<AttributeBinding> set = Collections.singleton( ( AttributeBinding ) entityIdentifier.getValueBinding() ); Set<AttributeBinding> set = Collections.singleton( (AttributeBinding) entityIdentifier.getValueBinding() );
return set; return set;
} }

View File

@ -40,10 +40,15 @@ public interface AttributeContainer extends Type {
public Set<Attribute> getAttributes(); public Set<Attribute> getAttributes();
public SingularAttribute getOrCreateSingularAttribute(String name); public SingularAttribute getOrCreateSingularAttribute(String name);
public PluralAttribute getOrCreatePluralAttribute(String name, PluralAttributeNature nature); public PluralAttribute getOrCreatePluralAttribute(String name, PluralAttributeNature nature);
public PluralAttribute getOrCreateBag(String name); public PluralAttribute getOrCreateBag(String name);
public PluralAttribute getOrCreateSet(String name); public PluralAttribute getOrCreateSet(String name);
public IndexedPluralAttribute getOrCreateList(String name); public IndexedPluralAttribute getOrCreateList(String name);
public IndexedPluralAttribute getOrCreateMap(String name); public IndexedPluralAttribute getOrCreateMap(String name);
/** /**