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 // initialize the rootProvider first
CriteriaInfoProvider rootProvider = new EntityCriteriaInfoProvider(( Queryable ) sessionFactory.getEntityPersister( rootEntityName ) ); CriteriaInfoProvider rootProvider = new EntityCriteriaInfoProvider(( Queryable ) sessionFactory.getEntityPersister( rootEntityName ) );
criteriaInfoMap.put( rootCriteria, rootProvider); 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 ); Criteria value = associationPathCriteriaMap.get( key );
CriteriaInfoProvider info = getPathInfo( key ); CriteriaInfoProvider info = getPathInfo( key );
criteriaInfoMap.put( value, info ); criteriaInfoMap.put( value, info );

View File

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

View File

@ -25,7 +25,6 @@
package org.hibernate.sql; package org.hibernate.sql;
/** /**
* An old Sybase-style join (before Sybase supported the ANSI style "inner join" etc syntax) * 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. * 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) { 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! //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 ") afterWhere.append( " and " )
.append( fkColumns[j] ) .append( fkColumns[j] )
.append( " " ); .append( " " );
if (joinType==JoinType.LEFT_OUTER_JOIN ) afterWhere.append("*"); if ( joinType == JoinType.LEFT_OUTER_JOIN ) {
afterWhere.append('='); afterWhere.append( '*' );
if (joinType==JoinType.RIGHT_OUTER_JOIN ) afterWhere.append("*"); }
afterWhere.append( '=' );
if ( joinType == JoinType.RIGHT_OUTER_JOIN ) {
afterWhere.append( "*" );
}
afterWhere.append (" ") afterWhere.append( " " )
.append(alias) .append( alias )
.append('.') .append( '.' )
.append( pkColumns[j] ); .append( pkColumns[j] );
} }
} }
public String toFromFragmentString() { public String toFromFragmentString() {
@ -70,8 +74,8 @@ public class Sybase11JoinFragment extends JoinFragment {
} }
public void addJoins(String fromFragment, String whereFragment) { public void addJoins(String fromFragment, String whereFragment) {
afterFrom.append(fromFragment); afterFrom.append( fromFragment );
afterWhere.append(whereFragment); afterWhere.append( whereFragment );
} }
public JoinFragment copy() { public JoinFragment copy() {
@ -82,20 +86,20 @@ public class Sybase11JoinFragment extends JoinFragment {
} }
public void addCondition(String alias, String[] columns, String condition) { public void addCondition(String alias, String[] columns, String condition) {
for ( int i=0; i<columns.length; i++ ) { for ( String column : columns ) {
afterWhere.append(" and ") afterWhere.append( " and " )
.append(alias) .append( alias )
.append('.') .append( '.' )
.append( columns[i] ) .append( column )
.append(condition); .append( condition );
} }
} }
public void addCrossJoin(String tableName, String alias) { public void addCrossJoin(String tableName, String alias) {
afterFrom.append(", ") afterFrom.append( ", " )
.append(tableName) .append( tableName )
.append(' ') .append( ' ' )
.append(alias); .append( alias );
} }
public void addCondition(String alias, String[] fkColumns, String[] pkColumns) { public void addCondition(String alias, String[] fkColumns, String[] pkColumns) {
@ -104,18 +108,24 @@ public class Sybase11JoinFragment extends JoinFragment {
} }
public boolean addCondition(String condition) { public boolean addCondition(String condition) {
return addCondition(afterWhere, condition); return addCondition( afterWhere, condition );
} }
public void addFromFragmentString(String fromFragmentString) { 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) { public void addJoin(
addJoin(tableName, alias, fkColumns, pkColumns, joinType); String tableName,
addCondition(on); 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. * @return The named child.
* @throws Exception Child was not found or was not unique. * @throws Exception Child was not found or was not unique.
*/ */
public static Element getUniqueChild(Element element, String tagName) public static Element getUniqueChild(Element element, String tagName) throws Exception {
throws Exception {
Iterator goodChildren = getChildrenByTagName( element, tagName ); Iterator goodChildren = getChildrenByTagName( element, tagName );
if ( goodChildren != null && goodChildren.hasNext() ) { if ( goodChildren != null && goodChildren.hasNext() ) {
Element child = (Element) goodChildren.next(); Element child = (Element) goodChildren.next();
if ( goodChildren.hasNext() ) { if ( goodChildren.hasNext() ) {
throw new Exception throw new Exception( "expected only one " + tagName + " tag" );
( "expected only one " + tagName + " tag" );
} }
return child; return child;
} }
else { else {
throw new Exception throw new Exception( "expected one " + tagName + " tag" );
( "expected one " + tagName + " tag" );
} }
} }
@ -101,8 +98,7 @@ public final class XmlHelper {
* @param tagName the name of the desired child * @param tagName the name of the desired child
* @return either the named child or null * @return either the named child or null
*/ */
public static Element getOptionalChild(Element element, String tagName) public static Element getOptionalChild(Element element, String tagName) throws Exception {
throws Exception {
return getOptionalChild( element, tagName, null ); return getOptionalChild( element, tagName, null );
} }
@ -126,8 +122,7 @@ public final class XmlHelper {
if ( goodChildren != null && goodChildren.hasNext() ) { if ( goodChildren != null && goodChildren.hasNext() ) {
Element child = (Element) goodChildren.next(); Element child = (Element) goodChildren.next();
if ( goodChildren.hasNext() ) { if ( goodChildren.hasNext() ) {
throw new Exception throw new Exception( "expected only one " + tagName + " tag" );
( "expected only one " + tagName + " tag" );
} }
return child; return child;
} }
@ -163,8 +158,8 @@ public final class XmlHelper {
NodeList children = element.getChildNodes(); NodeList children = element.getChildNodes();
StringBuilder result = new StringBuilder(""); StringBuilder result = new StringBuilder("");
for ( int i = 0; i < children.getLength() ; i++ ) { for ( int i = 0; i < children.getLength() ; i++ ) {
if ( children.item( i ).getNodeType() == Node.TEXT_NODE || if ( children.item( i ).getNodeType() == Node.TEXT_NODE
children.item( i ).getNodeType() == Node.CDATA_SECTION_NODE ) { || children.item( i ).getNodeType() == Node.CDATA_SECTION_NODE ) {
result.append( children.item( i ).getNodeValue() ); result.append( children.item( i ).getNodeValue() );
} }
// else if ( children.item( i ).getNodeType() == Node.COMMENT_NODE ) { // else if ( children.item( i ).getNodeType() == Node.COMMENT_NODE ) {
@ -210,7 +205,4 @@ public final class XmlHelper {
return false; 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.criteria.expression.CompoundSelectionImpl;
import org.hibernate.jpa.internal.EntityManagerFactoryImpl; import org.hibernate.jpa.internal.EntityManagerFactoryImpl;
import org.hibernate.jpa.internal.EntityManagerMessageLogger; import org.hibernate.jpa.internal.EntityManagerMessageLogger;
import org.hibernate.jpa.internal.HEMLogging;
import org.hibernate.jpa.internal.QueryImpl; import org.hibernate.jpa.internal.QueryImpl;
import org.hibernate.jpa.internal.StoredProcedureQueryImpl; import org.hibernate.jpa.internal.StoredProcedureQueryImpl;
import org.hibernate.jpa.internal.TransactionImpl; import org.hibernate.jpa.internal.TransactionImpl;
@ -144,8 +145,7 @@ import org.jboss.logging.Logger;
public abstract class AbstractEntityManagerImpl implements HibernateEntityManagerImplementor, Serializable { public abstract class AbstractEntityManagerImpl implements HibernateEntityManagerImplementor, Serializable {
private static final long serialVersionUID = 78818181L; private static final long serialVersionUID = 78818181L;
private static final EntityManagerMessageLogger LOG = Logger.getMessageLogger(EntityManagerMessageLogger.class, private static final EntityManagerMessageLogger LOG = HEMLogging.messageLogger( AbstractEntityManagerImpl.class );
AbstractEntityManagerImpl.class.getName());
private static final List<String> ENTITY_MANAGER_SPECIFIC_PROPERTIES = new ArrayList<String>(); private static final List<String> ENTITY_MANAGER_SPECIFIC_PROPERTIES = new ArrayList<String>();
@ -234,7 +234,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
} }
Object queryTimeout; Object queryTimeout;
if ( (queryTimeout = getProperties().get(QueryHints.SPEC_HINT_TIMEOUT)) != null ) { 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; Object lockTimeout;
if( (lockTimeout = getProperties().get( AvailableSettings.LOCK_TIMEOUT ))!=null){ if( (lockTimeout = getProperties().get( AvailableSettings.LOCK_TIMEOUT ))!=null){
@ -1138,21 +1138,21 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
throw new IllegalArgumentException( e.getMessage(), e ); throw new IllegalArgumentException( e.getMessage(), e );
} }
catch ( MappingException e ) { catch ( MappingException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) ); throw convert( new IllegalArgumentException( e.getMessage(), e ) );
} }
catch ( TypeMismatchException e ) { catch ( TypeMismatchException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) ); throw convert( new IllegalArgumentException( e.getMessage(), e ) );
} }
catch ( ClassCastException e ) { catch ( ClassCastException e ) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) ); throw convert( new IllegalArgumentException( e.getMessage(), e ) );
} }
catch ( RuntimeException e ) { catch ( RuntimeException e ) {
throw convert( e, lockOptions ); throw convert( e, lockOptions );
} }
finally { finally {
session.setCacheMode( previousCacheMode ); session.setCacheMode( previousCacheMode );
((SessionImplementor)session).getLoadQueryInfluencers().setFetchGraph( null ); ( (SessionImplementor) session ).getLoadQueryInfluencers().setFetchGraph( null );
((SessionImplementor)session).getLoadQueryInfluencers().setLoadGraph( null ); ( (SessionImplementor) session ).getLoadQueryInfluencers().setLoadGraph( null );
} }
} }
@ -1190,7 +1190,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
internalGetSession().persist( entity ); internalGetSession().persist( entity );
} }
catch ( MappingException e ) { catch ( MappingException e ) {
throw convert ( new IllegalArgumentException( e.getMessage() ) ) ; throw convert( new IllegalArgumentException( e.getMessage() ) ) ;
} }
catch ( RuntimeException e ) { catch ( RuntimeException e ) {
throw convert( e ); throw convert( e );
@ -1205,12 +1205,13 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
return ( A ) internalGetSession().merge( entity ); return ( A ) internalGetSession().merge( entity );
} }
catch ( ObjectDeletedException sse ) { catch ( ObjectDeletedException sse ) {
throw convert ( new IllegalArgumentException( sse ) ); throw convert( new IllegalArgumentException( sse ) );
} }
catch ( MappingException e ) { 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 ); throw convert( e );
} }
} }
@ -1222,9 +1223,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
internalGetSession().delete( entity ); internalGetSession().delete( entity );
} }
catch ( MappingException e ) { 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 ); throw convert( e );
} }
} }
@ -1269,10 +1271,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
session.refresh( entity ); session.refresh( entity );
} }
} }
catch ( MappingException e ) { catch (MappingException e) {
throw convert ( new IllegalArgumentException( e.getMessage(), e ) ); throw convert( new IllegalArgumentException( e.getMessage(), e ) );
} }
catch ( RuntimeException e ) { catch (RuntimeException e) {
throw convert( e, lockOptions ); throw convert( e, lockOptions );
} }
finally { finally {
@ -1288,14 +1290,14 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
if ( entity != null if ( entity != null
&& !( entity instanceof HibernateProxy ) && !( entity instanceof HibernateProxy )
&& internalGetSession().getSessionFactory().getClassMetadata( entity.getClass() ) == null ) { && 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 ); return internalGetSession().contains( entity );
} }
catch ( MappingException e ) { catch (MappingException e) {
throw new IllegalArgumentException( e.getMessage(), e ); throw new IllegalArgumentException( e.getMessage(), e );
} }
catch ( RuntimeException e ) { catch (RuntimeException e) {
throw convert( e ); throw convert( e );
} }
} }
@ -1309,7 +1311,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
} }
if ( !contains( entity ) ) { 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 ) ); return getLockModeType( internalGetSession().getCurrentLockMode( entity ) );
@ -1425,7 +1427,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
try { try {
internalGetSession().clear(); internalGetSession().clear();
} }
catch ( RuntimeException e ) { catch (RuntimeException e) {
throw convert( e ); throw convert( e );
} }
} }
@ -1436,7 +1438,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
try { try {
internalGetSession().evict( entity ); internalGetSession().evict( entity );
} }
catch ( RuntimeException e ) { catch (RuntimeException e) {
throw convert( e ); throw convert( e );
} }
} }
@ -1481,7 +1483,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
lockOptions = getLockRequest( lockModeType, properties ); lockOptions = getLockRequest( lockModeType, properties );
internalGetSession().buildLockRequest( lockOptions ).lock( entity ); internalGetSession().buildLockRequest( lockOptions ).lock( entity );
} }
catch ( RuntimeException e ) { catch (RuntimeException e) {
throw convert( e, lockOptions ); throw convert( e, lockOptions );
} }
} }
@ -1551,7 +1553,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
transactionManager.setRollbackOnly(); transactionManager.setRollbackOnly();
} }
} }
catch ( SystemException e ) { catch (SystemException e) {
throw new PersistenceException( "Unable to set the JTA transaction as RollbackOnly", 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.setExceptionMapper( new CallbackExceptionMapperImpl() );
callbackCoordinator.setAfterCompletionAction( new AfterCompletionActionImpl( session, transactionType ) ); callbackCoordinator.setAfterCompletionAction( new AfterCompletionActionImpl( session, transactionType ) );
} }
catch ( HibernateException he ) { catch (HibernateException he) {
throw convert( he ); throw convert( he );
} }
} }
@ -1687,7 +1689,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
public RuntimeException convert(RuntimeException e) { public RuntimeException convert(RuntimeException e) {
RuntimeException result = e; RuntimeException result = e;
if ( e instanceof HibernateException ) { if ( e instanceof HibernateException ) {
result = convert( ( HibernateException ) e ); result = convert( (HibernateException) e );
} }
else { else {
markForRollbackOnly(); markForRollbackOnly();
@ -1698,7 +1700,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
public RuntimeException convert(RuntimeException e, LockOptions lockOptions) { public RuntimeException convert(RuntimeException e, LockOptions lockOptions) {
RuntimeException result = e; RuntimeException result = e;
if ( e instanceof HibernateException ) { if ( e instanceof HibernateException ) {
result = convert( ( HibernateException ) e , lockOptions ); result = convert( (HibernateException) e , lockOptions );
} }
else { else {
markForRollbackOnly(); markForRollbackOnly();
@ -1709,7 +1711,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
@Override @Override
public RuntimeException convert(HibernateException e, LockOptions lockOptions) { public RuntimeException convert(HibernateException e, LockOptions lockOptions) {
if ( e instanceof StaleStateException ) { if ( e instanceof StaleStateException ) {
PersistenceException converted = wrapStaleStateException( ( StaleStateException ) e ); PersistenceException converted = wrapStaleStateException( (StaleStateException) e );
handlePersistenceException( converted ); handlePersistenceException( converted );
return converted; return converted;
} }
@ -1729,7 +1731,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
return converted; return converted;
} }
else if ( e instanceof org.hibernate.QueryTimeoutException ) { else if ( e instanceof org.hibernate.QueryTimeoutException ) {
QueryTimeoutException converted = new QueryTimeoutException(e.getMessage(), e); QueryTimeoutException converted = new QueryTimeoutException( e.getMessage(), e );
handlePersistenceException( converted ); handlePersistenceException( converted );
return converted; return converted;
} }