HHH-8741 - More checkstyle cleanups

This commit is contained in:
Steve Ebersole 2013-11-24 15:29:50 -06:00
parent 4c91944fd9
commit 77c85353ab
5 changed files with 88 additions and 84 deletions

View File

@ -220,9 +220,9 @@ public class CriteriaQueryTranslator implements CriteriaQuery {
// initialize the rootProvider first
CriteriaInfoProvider rootProvider = new EntityCriteriaInfoProvider(( Queryable ) sessionFactory.getEntityPersister( rootEntityName ) );
criteriaInfoMap.put( rootCriteria, rootProvider);
nameCriteriaInfoMap.put ( rootProvider.getName(), rootProvider );
nameCriteriaInfoMap.put( rootProvider.getName(), rootProvider );
for(final String key : associationPathCriteriaMap.keySet() ){
for ( final String key : associationPathCriteriaMap.keySet() ) {
Criteria value = associationPathCriteriaMap.get( key );
CriteriaInfoProvider info = getPathInfo( key );
criteriaInfoMap.put( value, info );

View File

@ -119,23 +119,23 @@ public class SQLQueryReturnProcessor {
public class ResultAliasContext {
public SQLLoadable getEntityPersister(String alias) {
return ( SQLLoadable ) alias2Persister.get( alias );
return (SQLLoadable) alias2Persister.get( alias );
}
public SQLLoadableCollection getCollectionPersister(String alias) {
return ( SQLLoadableCollection ) alias2CollectionPersister.get( alias );
return (SQLLoadableCollection) alias2CollectionPersister.get( alias );
}
public String getEntitySuffix(String alias) {
return ( String ) alias2Suffix.get( alias );
return (String) alias2Suffix.get( alias );
}
public String getCollectionSuffix(String alias) {
return ( String ) alias2CollectionSuffix.get ( alias );
return (String) alias2CollectionSuffix.get( alias );
}
public String getOwnerAlias(String alias) {
return ( String ) alias2OwnerAlias.get( alias );
return (String) alias2OwnerAlias.get( alias );
}
public Map getPropertyResultsMap(String alias) {

View File

@ -25,7 +25,6 @@
package org.hibernate.sql;
/**
* An old Sybase-style join (before Sybase supported the ANSI style "inner join" etc syntax)
* This is needed for Sybase 11.9.2 and earlier, using the HQL 2.* syntax with Collections.
@ -39,26 +38,31 @@ public class Sybase11JoinFragment extends JoinFragment {
public void addJoin(String tableName, String alias, String[] fkColumns, String[] pkColumns, JoinType joinType) {
addCrossJoin(tableName, alias);
addCrossJoin( tableName, alias );
for ( int j=0; j<fkColumns.length; j++) {
for ( int j = 0; j < fkColumns.length; j++ ) {
//full joins are not supported.. yet!
if (joinType==JoinType.FULL_JOIN ) throw new UnsupportedOperationException();
if ( joinType == JoinType.FULL_JOIN ) {
throw new UnsupportedOperationException();
}
afterWhere.append(" and ")
.append( fkColumns[j] )
.append( " " );
afterWhere.append( " and " )
.append( fkColumns[j] )
.append( " " );
if (joinType==JoinType.LEFT_OUTER_JOIN ) afterWhere.append("*");
afterWhere.append('=');
if (joinType==JoinType.RIGHT_OUTER_JOIN ) afterWhere.append("*");
if ( joinType == JoinType.LEFT_OUTER_JOIN ) {
afterWhere.append( '*' );
}
afterWhere.append( '=' );
if ( joinType == JoinType.RIGHT_OUTER_JOIN ) {
afterWhere.append( "*" );
}
afterWhere.append (" ")
.append(alias)
.append('.')
.append( pkColumns[j] );
afterWhere.append( " " )
.append( alias )
.append( '.' )
.append( pkColumns[j] );
}
}
public String toFromFragmentString() {
@ -70,8 +74,8 @@ public class Sybase11JoinFragment extends JoinFragment {
}
public void addJoins(String fromFragment, String whereFragment) {
afterFrom.append(fromFragment);
afterWhere.append(whereFragment);
afterFrom.append( fromFragment );
afterWhere.append( whereFragment );
}
public JoinFragment copy() {
@ -82,20 +86,20 @@ public class Sybase11JoinFragment extends JoinFragment {
}
public void addCondition(String alias, String[] columns, String condition) {
for ( int i=0; i<columns.length; i++ ) {
afterWhere.append(" and ")
.append(alias)
.append('.')
.append( columns[i] )
.append(condition);
for ( String column : columns ) {
afterWhere.append( " and " )
.append( alias )
.append( '.' )
.append( column )
.append( condition );
}
}
public void addCrossJoin(String tableName, String alias) {
afterFrom.append(", ")
.append(tableName)
.append(' ')
.append(alias);
afterFrom.append( ", " )
.append( tableName )
.append( ' ' )
.append( alias );
}
public void addCondition(String alias, String[] fkColumns, String[] pkColumns) {
@ -104,18 +108,24 @@ public class Sybase11JoinFragment extends JoinFragment {
}
public boolean addCondition(String condition) {
return addCondition(afterWhere, condition);
return addCondition( afterWhere, condition );
}
public void addFromFragmentString(String fromFragmentString) {
afterFrom.append(fromFragmentString);
afterFrom.append( fromFragmentString );
}
public void addJoin(String tableName, String alias, String[] fkColumns, String[] pkColumns, JoinType joinType, String on) {
addJoin(tableName, alias, fkColumns, pkColumns, joinType);
addCondition(on);
public void addJoin(
String tableName,
String alias,
String[] fkColumns,
String[] pkColumns,
JoinType joinType,
String on) {
addJoin( tableName, alias, fkColumns, pkColumns, joinType );
addCondition( on );
}
}

View File

@ -74,21 +74,18 @@ public final class XmlHelper {
* @return The named child.
* @throws Exception Child was not found or was not unique.
*/
public static Element getUniqueChild(Element element, String tagName)
throws Exception {
public static Element getUniqueChild(Element element, String tagName) throws Exception {
Iterator goodChildren = getChildrenByTagName( element, tagName );
if ( goodChildren != null && goodChildren.hasNext() ) {
Element child = (Element) goodChildren.next();
if ( goodChildren.hasNext() ) {
throw new Exception
( "expected only one " + tagName + " tag" );
throw new Exception( "expected only one " + tagName + " tag" );
}
return child;
}
else {
throw new Exception
( "expected one " + tagName + " tag" );
throw new Exception( "expected one " + tagName + " tag" );
}
}
@ -101,8 +98,7 @@ public final class XmlHelper {
* @param tagName the name of the desired child
* @return either the named child or null
*/
public static Element getOptionalChild(Element element, String tagName)
throws Exception {
public static Element getOptionalChild(Element element, String tagName) throws Exception {
return getOptionalChild( element, tagName, null );
}
@ -126,8 +122,7 @@ public final class XmlHelper {
if ( goodChildren != null && goodChildren.hasNext() ) {
Element child = (Element) goodChildren.next();
if ( goodChildren.hasNext() ) {
throw new Exception
( "expected only one " + tagName + " tag" );
throw new Exception( "expected only one " + tagName + " tag" );
}
return child;
}
@ -163,8 +158,8 @@ public final class XmlHelper {
NodeList children = element.getChildNodes();
StringBuilder result = new StringBuilder("");
for ( int i = 0; i < children.getLength() ; i++ ) {
if ( children.item( i ).getNodeType() == Node.TEXT_NODE ||
children.item( i ).getNodeType() == Node.CDATA_SECTION_NODE ) {
if ( children.item( i ).getNodeType() == Node.TEXT_NODE
|| children.item( i ).getNodeType() == Node.CDATA_SECTION_NODE ) {
result.append( children.item( i ).getNodeValue() );
}
// else if ( children.item( i ).getNodeType() == Node.COMMENT_NODE ) {
@ -210,7 +205,4 @@ public final class XmlHelper {
return false;
}
}

View File

@ -119,6 +119,7 @@ import org.hibernate.jpa.criteria.compile.CriteriaCompiler;
import org.hibernate.jpa.criteria.expression.CompoundSelectionImpl;
import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
import org.hibernate.jpa.internal.EntityManagerMessageLogger;
import org.hibernate.jpa.internal.HEMLogging;
import org.hibernate.jpa.internal.QueryImpl;
import org.hibernate.jpa.internal.StoredProcedureQueryImpl;
import org.hibernate.jpa.internal.TransactionImpl;
@ -144,8 +145,7 @@ import org.jboss.logging.Logger;
public abstract class AbstractEntityManagerImpl implements HibernateEntityManagerImplementor, Serializable {
private static final long serialVersionUID = 78818181L;
private static final EntityManagerMessageLogger LOG = Logger.getMessageLogger(EntityManagerMessageLogger.class,
AbstractEntityManagerImpl.class.getName());
private static final EntityManagerMessageLogger LOG = HEMLogging.messageLogger( AbstractEntityManagerImpl.class );
private static final List<String> ENTITY_MANAGER_SPECIFIC_PROPERTIES = new ArrayList<String>();
@ -234,7 +234,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
}
Object queryTimeout;
if ( (queryTimeout = getProperties().get(QueryHints.SPEC_HINT_TIMEOUT)) != null ) {
query.setHint ( QueryHints.SPEC_HINT_TIMEOUT, queryTimeout );
query.setHint( QueryHints.SPEC_HINT_TIMEOUT, queryTimeout );
}
Object lockTimeout;
if( (lockTimeout = getProperties().get( AvailableSettings.LOCK_TIMEOUT ))!=null){
@ -1138,21 +1138,21 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
throw new IllegalArgumentException( e.getMessage(), e );
}
catch ( MappingException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) );
throw convert( new IllegalArgumentException( e.getMessage(), e ) );
}
catch ( TypeMismatchException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) );
throw convert( new IllegalArgumentException( e.getMessage(), e ) );
}
catch ( ClassCastException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) );
throw convert( new IllegalArgumentException( e.getMessage(), e ) );
}
catch ( RuntimeException e ) {
throw convert( e, lockOptions );
}
finally {
session.setCacheMode( previousCacheMode );
((SessionImplementor)session).getLoadQueryInfluencers().setFetchGraph( null );
((SessionImplementor)session).getLoadQueryInfluencers().setLoadGraph( null );
( (SessionImplementor) session ).getLoadQueryInfluencers().setFetchGraph( null );
( (SessionImplementor) session ).getLoadQueryInfluencers().setLoadGraph( null );
}
}
@ -1190,7 +1190,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
internalGetSession().persist( entity );
}
catch ( MappingException e ) {
throw convert ( new IllegalArgumentException( e.getMessage() ) ) ;
throw convert( new IllegalArgumentException( e.getMessage() ) ) ;
}
catch ( RuntimeException e ) {
throw convert( e );
@ -1205,12 +1205,13 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
return ( A ) internalGetSession().merge( entity );
}
catch ( ObjectDeletedException sse ) {
throw convert ( new IllegalArgumentException( sse ) );
throw convert( new IllegalArgumentException( sse ) );
}
catch ( MappingException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) );
throw convert( new IllegalArgumentException( e.getMessage(), e ) );
}
catch ( RuntimeException e ) { //including HibernateException
catch ( RuntimeException e ) {
//including HibernateException
throw convert( e );
}
}
@ -1222,9 +1223,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
internalGetSession().delete( entity );
}
catch ( MappingException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) );
throw convert( new IllegalArgumentException( e.getMessage(), e ) );
}
catch ( RuntimeException e ) { //including HibernateException
catch ( RuntimeException e ) {
//including HibernateException
throw convert( e );
}
}
@ -1269,10 +1271,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
session.refresh( entity );
}
}
catch ( MappingException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) );
catch (MappingException e) {
throw convert( new IllegalArgumentException( e.getMessage(), e ) );
}
catch ( RuntimeException e ) {
catch (RuntimeException e) {
throw convert( e, lockOptions );
}
finally {
@ -1288,14 +1290,14 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
if ( entity != null
&& !( entity instanceof HibernateProxy )
&& internalGetSession().getSessionFactory().getClassMetadata( entity.getClass() ) == null ) {
throw convert ( new IllegalArgumentException( "Not an entity:" + entity.getClass() ) );
throw convert( new IllegalArgumentException( "Not an entity:" + entity.getClass() ) );
}
return internalGetSession().contains( entity );
}
catch ( MappingException e ) {
catch (MappingException e) {
throw new IllegalArgumentException( e.getMessage(), e );
}
catch ( RuntimeException e ) {
catch (RuntimeException e) {
throw convert( e );
}
}
@ -1309,7 +1311,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
}
if ( !contains( entity ) ) {
throw convert (new IllegalArgumentException( "entity not in the persistence context" ) );
throw convert( new IllegalArgumentException( "entity not in the persistence context" ) );
}
return getLockModeType( internalGetSession().getCurrentLockMode( entity ) );
@ -1425,7 +1427,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
try {
internalGetSession().clear();
}
catch ( RuntimeException e ) {
catch (RuntimeException e) {
throw convert( e );
}
}
@ -1436,7 +1438,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
try {
internalGetSession().evict( entity );
}
catch ( RuntimeException e ) {
catch (RuntimeException e) {
throw convert( e );
}
}
@ -1481,7 +1483,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
lockOptions = getLockRequest( lockModeType, properties );
internalGetSession().buildLockRequest( lockOptions ).lock( entity );
}
catch ( RuntimeException e ) {
catch (RuntimeException e) {
throw convert( e, lockOptions );
}
}
@ -1551,7 +1553,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
transactionManager.setRollbackOnly();
}
}
catch ( SystemException e ) {
catch (SystemException e) {
throw new PersistenceException( "Unable to set the JTA transaction as RollbackOnly", e );
}
}
@ -1626,7 +1628,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
callbackCoordinator.setExceptionMapper( new CallbackExceptionMapperImpl() );
callbackCoordinator.setAfterCompletionAction( new AfterCompletionActionImpl( session, transactionType ) );
}
catch ( HibernateException he ) {
catch (HibernateException he) {
throw convert( he );
}
}
@ -1687,7 +1689,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
public RuntimeException convert(RuntimeException e) {
RuntimeException result = e;
if ( e instanceof HibernateException ) {
result = convert( ( HibernateException ) e );
result = convert( (HibernateException) e );
}
else {
markForRollbackOnly();
@ -1698,7 +1700,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
public RuntimeException convert(RuntimeException e, LockOptions lockOptions) {
RuntimeException result = e;
if ( e instanceof HibernateException ) {
result = convert( ( HibernateException ) e , lockOptions );
result = convert( (HibernateException) e , lockOptions );
}
else {
markForRollbackOnly();
@ -1709,7 +1711,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
@Override
public RuntimeException convert(HibernateException e, LockOptions lockOptions) {
if ( e instanceof StaleStateException ) {
PersistenceException converted = wrapStaleStateException( ( StaleStateException ) e );
PersistenceException converted = wrapStaleStateException( (StaleStateException) e );
handlePersistenceException( converted );
return converted;
}
@ -1729,7 +1731,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
return converted;
}
else if ( e instanceof org.hibernate.QueryTimeoutException ) {
QueryTimeoutException converted = new QueryTimeoutException(e.getMessage(), e);
QueryTimeoutException converted = new QueryTimeoutException( e.getMessage(), e );
handlePersistenceException( converted );
return converted;
}