Fix some obvious log or exception message issues

This commit is contained in:
Nathan Xu 2020-02-24 09:51:54 -05:00 committed by Andrea Boriero
parent 09c33446ff
commit d8d8d6e112
51 changed files with 84 additions and 84 deletions

View File

@ -20,7 +20,7 @@ public class UnknownProfileException extends HibernateException {
* @param name The profile name that was unknown. * @param name The profile name that was unknown.
*/ */
public UnknownProfileException(String name) { public UnknownProfileException(String name) {
super( "Unknow fetch profile [" + name + "]" ); super( "Unknown fetch profile [" + name + "]" );
this.name = name; this.name = name;
} }

View File

@ -128,7 +128,7 @@ public void execute() throws HibernateException {
final PersistenceContext persistenceContext = session.getPersistenceContextInternal(); final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
final EntityEntry entry = persistenceContext.removeEntry( instance ); final EntityEntry entry = persistenceContext.removeEntry( instance );
if ( entry == null ) { if ( entry == null ) {
throw new AssertionFailure( "possible nonthreadsafe access to session" ); throw new AssertionFailure( "possible non-threadsafe access to session" );
} }
entry.postDelete(); entry.postDelete();

View File

@ -211,7 +211,7 @@ public void execute() throws HibernateException {
final EntityEntry entry = session.getPersistenceContextInternal().getEntry( instance ); final EntityEntry entry = session.getPersistenceContextInternal().getEntry( instance );
if ( entry == null ) { if ( entry == null ) {
throw new AssertionFailure( "possible nonthreadsafe access to session" ); throw new AssertionFailure( "possible non-threadsafe access to session" );
} }
if ( entry.getStatus()==Status.MANAGED || persister.isVersionPropertyGenerated() ) { if ( entry.getStatus()==Status.MANAGED || persister.isVersionPropertyGenerated() ) {

View File

@ -118,7 +118,7 @@ public static URL getURLFromPath(String jarPath) {
jarUrl = new URL( "file:" + jarPath ); jarUrl = new URL( "file:" + jarPath );
} }
catch (MalformedURLException ee) { catch (MalformedURLException ee) {
throw new IllegalArgumentException( "Unable to find jar:" + jarPath, ee ); throw new IllegalArgumentException( "Unable to find jar: " + jarPath, ee );
} }
} }
return jarUrl; return jarUrl;

View File

@ -39,7 +39,7 @@ public JarProtocolArchiveDescriptor(
final String urlFile = url.getFile(); final String urlFile = url.getFile();
final int subEntryIndex = urlFile.lastIndexOf( '!' ); final int subEntryIndex = urlFile.lastIndexOf( '!' );
if ( subEntryIndex == -1 ) { if ( subEntryIndex == -1 ) {
throw new AssertionFailure( "JAR URL does not contain '!/' :" + url ); throw new AssertionFailure( "JAR URL does not contain '!/' : " + url );
} }
final String subEntry; final String subEntry;

View File

@ -168,7 +168,7 @@ public Properties loadProperties(File file) {
} }
catch (FileNotFoundException e) { catch (FileNotFoundException e) {
throw new ConfigurationException( throw new ConfigurationException(
"Unable locate specified properties file [" + file.getAbsolutePath() + "]", "Unable to locate specified properties file [" + file.getAbsolutePath() + "]",
e e
); );
} }

View File

@ -73,7 +73,7 @@ public JaxbCfgHibernateConfiguration unmarshal(InputStream stream, Origin origin
} }
} }
catch ( XMLStreamException e ) { catch ( XMLStreamException e ) {
throw new HibernateException( "Unable to create stax reader", e ); throw new HibernateException( "Unable to create StAX reader", e );
} }
} }
@ -104,7 +104,7 @@ private JaxbCfgHibernateConfiguration unmarshal(XMLEventReader staxEventReader,
} }
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new HibernateException( "Error accessing stax stream", e ); throw new HibernateException( "Error accessing StAX stream", e );
} }
if ( event == null ) { if ( event == null ) {

View File

@ -298,7 +298,7 @@ public void addEntityBinding(PersistentClass persistentClass) throws DuplicateMa
if ( matchingPersistentClass != null ) { if ( matchingPersistentClass != null ) {
throw new DuplicateMappingException( throw new DuplicateMappingException(
String.format( String.format(
"The [%s] and [%s] entities share the same JPA entity name: [%s] which is not allowed!", "The [%s] and [%s] entities share the same JPA entity name: [%s], which is not allowed!",
matchingPersistentClass.getClassName(), matchingPersistentClass.getClassName(),
persistentClass.getClassName(), persistentClass.getClassName(),
jpaEntityName jpaEntityName
@ -478,7 +478,7 @@ public void addIdentifierGenerator(IdentifierGeneratorDefinition generator) {
final IdentifierGeneratorDefinition old = idGeneratorDefinitionMap.put( generator.getName(), generator ); final IdentifierGeneratorDefinition old = idGeneratorDefinitionMap.put( generator.getName(), generator );
if ( old != null && !old.equals( generator ) ) { if ( old != null && !old.equals( generator ) ) {
if ( bootstrapContext.getJpaCompliance().isGlobalGeneratorScopeEnabled() ) { if ( bootstrapContext.getJpaCompliance().isGlobalGeneratorScopeEnabled() ) {
throw new IllegalArgumentException( "Duplicate generator name " + old.getName() + " you will likely want to set the property " + AvailableSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE + " to false " ); throw new IllegalArgumentException( "Duplicate generator name " + old.getName() + "; you will likely want to set the property " + AvailableSettings.JPA_ID_GENERATOR_GLOBAL_SCOPE_COMPLIANCE + " to false " );
} }
else { else {
log.duplicateGeneratorName( old.getName() ); log.duplicateGeneratorName( old.getName() );

View File

@ -97,7 +97,7 @@ private static StandardServiceRegistry getStandardServiceRegistry(ServiceRegistr
} }
else if ( BootstrapServiceRegistry.class.isInstance( serviceRegistry ) ) { else if ( BootstrapServiceRegistry.class.isInstance( serviceRegistry ) ) {
log.debugf( log.debugf(
"ServiceRegistry passed to MetadataBuilder was a BootstrapServiceRegistry; this likely wont end well" + "ServiceRegistry passed to MetadataBuilder was a BootstrapServiceRegistry; this likely won't end well " +
"if attempt is made to build SessionFactory" "if attempt is made to build SessionFactory"
); );
return new StandardServiceRegistryBuilder( (BootstrapServiceRegistry) serviceRegistry ).build(); return new StandardServiceRegistryBuilder( (BootstrapServiceRegistry) serviceRegistry ).build();

View File

@ -74,7 +74,7 @@ protected XMLEventReader createReader(InputStream stream, Origin origin) {
return new BufferedXMLEventReader( staxReader, 100 ); return new BufferedXMLEventReader( staxReader, 100 );
} }
catch ( XMLStreamException e ) { catch ( XMLStreamException e ) {
throw new MappingException( "Unable to create stax reader", e, origin ); throw new MappingException( "Unable to create StAX reader", e, origin );
} }
} }
@ -92,7 +92,7 @@ protected XMLEventReader createReader(Source source, Origin origin) {
return new BufferedXMLEventReader( staxReader, 100 ); return new BufferedXMLEventReader( staxReader, 100 );
} }
catch ( XMLStreamException e ) { catch ( XMLStreamException e ) {
throw new MappingException( "Unable to create stax reader", e, origin ); throw new MappingException( "Unable to create StAX reader", e, origin );
} }
} }
@ -138,7 +138,7 @@ protected StartElement seekRootElementStartEvent(XMLEventReader staxEventReader,
} }
} }
catch ( Exception e ) { catch ( Exception e ) {
throw new MappingException( "Error accessing stax stream", e, origin ); throw new MappingException( "Error accessing StAX stream", e, origin );
} }
if ( rootElementStartEvent == null ) { if ( rootElementStartEvent == null ) {

View File

@ -92,7 +92,7 @@ private void register(String name, TypeDefinition typeDefinition, DuplicationStr
throw new IllegalArgumentException( throw new IllegalArgumentException(
String.format( String.format(
Locale.ROOT, Locale.ROOT,
"Attempted to ovewrite registration [%s] for type definition.", "Attempted to overwrite registration [%s] for type definition.",
name name
) )
); );

View File

@ -17,8 +17,8 @@
public class NoCacheRegionFactoryAvailableException extends CacheException { public class NoCacheRegionFactoryAvailableException extends CacheException {
private static final String MSG = String.format( private static final String MSG = String.format(
"Second-level cache is used in the application, but property %s is not given; " + "Second-level cache is used in the application, but property %s is not given; " +
"please either disable second level cache or set correct region factory using the %s setting " + "please either disable second-level cache or set correct region factory using the %s setting " +
"and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the " + "and make sure the second-level cache provider (hibernate-infinispan, e.g.) is available on the " +
"classpath.", "classpath.",
Environment.CACHE_REGION_FACTORY, Environment.CACHE_REGION_FACTORY,
Environment.CACHE_REGION_FACTORY Environment.CACHE_REGION_FACTORY

View File

@ -317,7 +317,7 @@ else if ( property.isAnnotationPresent( CollectionType.class ) ) {
} }
else { else {
throw new AnnotationException( throw new AnnotationException(
"Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: " "Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @ElementCollection: "
+ StringHelper.qualify( entityName, property.getName() ) + StringHelper.qualify( entityName, property.getName() )
); );
} }
@ -347,28 +347,28 @@ private static CollectionBinder getBinderFromBasicCollectionType(Class<?> clazz,
String entityName, boolean isIndexed) { String entityName, boolean isIndexed) {
if ( java.util.Set.class.equals( clazz) ) { if ( java.util.Set.class.equals( clazz) ) {
if ( property.isAnnotationPresent( CollectionId.class) ) { if ( property.isAnnotationPresent( CollectionId.class) ) {
throw new AnnotationException("Set do not support @CollectionId: " throw new AnnotationException("Set does not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) ); + StringHelper.qualify( entityName, property.getName() ) );
} }
return new SetBinder( false ); return new SetBinder( false );
} }
else if ( java.util.SortedSet.class.equals( clazz ) ) { else if ( java.util.SortedSet.class.equals( clazz ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) { if ( property.isAnnotationPresent( CollectionId.class ) ) {
throw new AnnotationException( "Set do not support @CollectionId: " throw new AnnotationException( "SortedSet does not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) ); + StringHelper.qualify( entityName, property.getName() ) );
} }
return new SetBinder( true ); return new SetBinder( true );
} }
else if ( java.util.Map.class.equals( clazz ) ) { else if ( java.util.Map.class.equals( clazz ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) { if ( property.isAnnotationPresent( CollectionId.class ) ) {
throw new AnnotationException( "Map do not support @CollectionId: " throw new AnnotationException( "Map does not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) ); + StringHelper.qualify( entityName, property.getName() ) );
} }
return new MapBinder( false ); return new MapBinder( false );
} }
else if ( java.util.SortedMap.class.equals( clazz ) ) { else if ( java.util.SortedMap.class.equals( clazz ) ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) { if ( property.isAnnotationPresent( CollectionId.class ) ) {
throw new AnnotationException( "Map do not support @CollectionId: " throw new AnnotationException( "SortedMap does not support @CollectionId: "
+ StringHelper.qualify( entityName, property.getName() ) ); + StringHelper.qualify( entityName, property.getName() ) );
} }
return new MapBinder( true ); return new MapBinder( true );
@ -385,7 +385,7 @@ else if ( java.util.List.class.equals( clazz ) ) {
if ( isIndexed ) { if ( isIndexed ) {
if ( property.isAnnotationPresent( CollectionId.class ) ) { if ( property.isAnnotationPresent( CollectionId.class ) ) {
throw new AnnotationException( throw new AnnotationException(
"List do not support @CollectionId and @OrderColumn (or @IndexColumn) at the same time: " "List does not support @CollectionId and @OrderColumn (or @IndexColumn) at the same time: "
+ StringHelper.qualify( entityName, property.getName() ) ); + StringHelper.qualify( entityName, property.getName() ) );
} }
return new ListBinder(); return new ListBinder();
@ -666,7 +666,7 @@ else if ( comparatorSort != null ) {
if ( isSortedCollection ) { if ( isSortedCollection ) {
if ( ! hadExplicitSort && !hadOrderBy ) { if ( ! hadExplicitSort && !hadOrderBy ) {
throw new AnnotationException( throw new AnnotationException(
"A sorted collection must define and ordering or sorting : " + safeCollectionRole() "A sorted collection must define an ordering or sorting : " + safeCollectionRole()
); );
} }
} }
@ -723,7 +723,7 @@ else if ( manyToAny != null ) {
} }
else { else {
throw new AssertionFailure( throw new AssertionFailure(
"Define fetch strategy on a property not annotated with @ManyToOne nor @OneToMany nor @CollectionOfElements" "Define fetch strategy on a property not annotated with @ManyToOne nor @OneToMany nor @ElementCollection"
); );
} }
if ( lazy != null ) { if ( lazy != null ) {
@ -989,7 +989,7 @@ private void bindFilters(boolean hasAssociationTable) {
} }
else { else {
throw new AnnotationException( throw new AnnotationException(
"Illegal use of @FilterJoinTable on an association without join table:" "Illegal use of @FilterJoinTable on an association without join table: "
+ StringHelper.qualify( propertyHolder.getPath(), propertyName ) + StringHelper.qualify( propertyHolder.getPath(), propertyName )
); );
} }
@ -1004,7 +1004,7 @@ private void bindFilters(boolean hasAssociationTable) {
} }
else { else {
throw new AnnotationException( throw new AnnotationException(
"Illegal use of @FilterJoinTable on an association without join table:" "Illegal use of @FilterJoinTable on an association without join table: "
+ StringHelper.qualify( propertyHolder.getPath(), propertyName ) + StringHelper.qualify( propertyHolder.getPath(), propertyName )
); );
} }
@ -1067,7 +1067,7 @@ private void bindFilters(boolean hasAssociationTable) {
} }
else { else {
throw new AnnotationException( throw new AnnotationException(
"Illegal use of @WhereJoinTable on an association without join table:" "Illegal use of @WhereJoinTable on an association without join table: "
+ StringHelper.qualify( propertyHolder.getPath(), propertyName ) + StringHelper.qualify( propertyHolder.getPath(), propertyName )
); );
} }
@ -1313,7 +1313,7 @@ private void bindManyToManySecondPass(
LOG.debugf("Binding a OneToMany: %s through an association table", path); LOG.debugf("Binding a OneToMany: %s through an association table", path);
} }
else if (isCollectionOfEntities) { else if (isCollectionOfEntities) {
LOG.debugf("Binding as ManyToMany: %s", path); LOG.debugf("Binding a ManyToMany: %s", path);
} }
else if (anyAnn != null) { else if (anyAnn != null) {
LOG.debugf("Binding a ManyToAny: %s", path); LOG.debugf("Binding a ManyToAny: %s", path);
@ -1365,7 +1365,7 @@ else if ( anyAnn != null ) {
} }
catch (MappingException e) { catch (MappingException e) {
throw new AnnotationException( throw new AnnotationException(
"mappedBy reference an unknown target entity property: " "mappedBy references an unknown target entity property: "
+ collType + "." + joinColumns[0].getMappedBy() + " in " + collType + "." + joinColumns[0].getMappedBy() + " in "
+ collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName() + collValue.getOwnerEntityName() + "." + joinColumns[0].getPropertyName()
); );
@ -1671,7 +1671,7 @@ private static void checkFilterConditions(Collection collValue) {
!( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter !( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter
collValue.getElement().getFetchMode() != FetchMode.JOIN ) { collValue.getElement().getFetchMode() != FetchMode.JOIN ) {
throw new MappingException( throw new MappingException(
"@ManyToMany or @CollectionOfElements defining filter or where without join fetching " "@ManyToMany or @ElementCollection defining filter or where without join fetching "
+ "not valid within collection using join fetching[" + collValue.getRole() + "]" + "not valid within collection using join fetching[" + collValue.getRole() + "]"
); );
} }

View File

@ -532,7 +532,7 @@ else if ( current instanceof Formula ) {
return targetValue; return targetValue;
} }
else { else {
throw new AssertionFailure( "Unknown type encounters for map key: " + value.getClass() ); throw new AssertionFailure( "Unknown type encountered for map key: " + value.getClass() );
} }
} }

View File

@ -362,7 +362,7 @@ private ValueGeneration getValueGenerationFromAnnotations(XProperty property) {
if ( candidate != null ) { if ( candidate != null ) {
if ( valueGeneration != null ) { if ( valueGeneration != null ) {
throw new AnnotationException( throw new AnnotationException(
"Only one generator annotation is allowed:" + StringHelper.qualify( "Only one generator annotation is allowed: " + StringHelper.qualify(
holder.getPath(), holder.getPath(),
name name
) )
@ -436,7 +436,7 @@ private <A extends Annotation> AnnotationValueGeneration<A> instantiateAndInitia
} }
catch (Exception e) { catch (Exception e) {
throw new AnnotationException( throw new AnnotationException(
"Exception occurred during processing of generator annotation:" + StringHelper.qualify( "Exception occurred during processing of generator annotation: " + StringHelper.qualify(
holder.getPath(), holder.getPath(),
name name
), e ), e

View File

@ -234,7 +234,7 @@ else if ( value instanceof ToOne ) {
} }
catch (ClassCastException e) { catch (ClassCastException e) {
throw new MappingException( throw new MappingException(
"dotted notation reference neither a component nor a many/one to one", e "dotted notation references neither a component nor a many/one to one", e
); );
} }
} }
@ -250,13 +250,13 @@ else if ( value instanceof ToOne ) {
} }
catch (ClassCastException e) { catch (ClassCastException e) {
throw new MappingException( throw new MappingException(
"dotted notation reference neither a component nor a many/one to one", e "dotted notation references neither a component nor a many/one to one", e
); );
} }
} }
} }
else { else {
throw new MappingException( "dotted notation reference neither a component nor a many/one to one" ); throw new MappingException( "dotted notation references neither a component nor a many/one to one" );
} }
return parentPropIter; return parentPropIter;
} }

View File

@ -210,7 +210,7 @@ else if ( Calendar.class.isAssignableFrom( valueJavaType ) ) {
} }
case TIME: { case TIME: {
throw new NotYetImplementedException( throw new NotYetImplementedException(
"Calendar cannot persist TIME only" + StringHelper.qualify( persistentClassName, propertyName ) "Calendar cannot persist TIME only: " + StringHelper.qualify( persistentClassName, propertyName )
); );
} }
default: { default: {
@ -492,7 +492,7 @@ public void fillSimpleValue() {
if ( ! BinderHelper.isEmptyAnnotationValue( explicitType ) ) { if ( ! BinderHelper.isEmptyAnnotationValue( explicitType ) ) {
throw new AnnotationException( throw new AnnotationException(
String.format( String.format(
"AttributeConverter and explicit Type cannot be applied to same attribute [%s.%s];" + "AttributeConverter and explicit Type cannot be applied to same attribute [%s.%s]; " +
"remove @Type or specify @Convert(disableConversion = true)", "remove @Type or specify @Convert(disableConversion = true)",
persistentClassName, persistentClassName,
propertyName propertyName

View File

@ -640,7 +640,7 @@ else if ( value instanceof DependantValue ) {
//implicit case, we hope PK and FK columns are in the same order //implicit case, we hope PK and FK columns are in the same order
if ( columns.length != referencedEntity.getIdentifier().getColumnSpan() ) { if ( columns.length != referencedEntity.getIdentifier().getColumnSpan() ) {
throw new AnnotationException( throw new AnnotationException(
"A Foreign key refering " + referencedEntity.getEntityName() "A Foreign key referring " + referencedEntity.getEntityName()
+ " from " + associatedClass.getEntityName() + " from " + associatedClass.getEntityName()
+ " has the wrong number of column. should be " + referencedEntity.getIdentifier() + " has the wrong number of column. should be " + referencedEntity.getIdentifier()
.getColumnSpan() .getColumnSpan()

View File

@ -1675,7 +1675,7 @@ private void getAccessType(List<Annotation> annotationList, Element element) {
type = AccessType.valueOf( access ); type = AccessType.valueOf( access );
} }
catch ( IllegalArgumentException e ) { catch ( IllegalArgumentException e ) {
throw new AnnotationException( access + " is not a valid access type. Check you xml confguration." ); throw new AnnotationException( access + " is not a valid access type. Check you xml configuration." );
} }
if ( ( AccessType.PROPERTY.equals( type ) && this.element instanceof Method ) || if ( ( AccessType.PROPERTY.equals( type ) && this.element instanceof Method ) ||
@ -1881,7 +1881,7 @@ private Access getAccessType(Element tree, XMLContext.Default defaults) {
type = AccessType.valueOf( access ); type = AccessType.valueOf( access );
} }
catch ( IllegalArgumentException e ) { catch ( IllegalArgumentException e ) {
throw new AnnotationException( access + " is not a valid access type. Check you xml confguration." ); throw new AnnotationException( access + " is not a valid access type. Check you xml configuration." );
} }
ad.setValue( "value", type ); ad.setValue( "value", type );
return AnnotationFactory.create( ad ); return AnnotationFactory.create( ad );
@ -2481,7 +2481,7 @@ public static List buildNamedQueries(
copyStringAttribute( ann, subelement, "name", false ); copyStringAttribute( ann, subelement, "name", false );
Element queryElt = subelement.element( "query" ); Element queryElt = subelement.element( "query" );
if ( queryElt == null ) { if ( queryElt == null ) {
throw new AnnotationException( "No <query> element found." + SCHEMA_VALIDATION ); throw new AnnotationException( "No <query> element found. " + SCHEMA_VALIDATION );
} }
copyStringElement( queryElt, ann, "query" ); copyStringElement( queryElt, ann, "query" );
List<Element> elements = subelement.elements( "hint" ); List<Element> elements = subelement.elements( "hint" );
@ -2614,7 +2614,7 @@ else if ( "INTEGER".equals( value ) ) {
} }
else { else {
throw new AnnotationException( throw new AnnotationException(
"Unknown DiscrimiatorType in XML: " + value + " (" + SCHEMA_VALIDATION + ")" "Unknown DiscriminatorType in XML: " + value + " (" + SCHEMA_VALIDATION + ")"
); );
} }
} }

View File

@ -136,7 +136,7 @@ private void setAccess( String access, Default defaultType) {
type = AccessType.valueOf( access ); type = AccessType.valueOf( access );
} }
catch ( IllegalArgumentException e ) { catch ( IllegalArgumentException e ) {
throw new AnnotationException( "Invalid access type " + access + " (check your xml configuration)" ); throw new AnnotationException( "Invalid access type: " + access + " (check your xml configuration)" );
} }
defaultType.setAccess( type ); defaultType.setAccess( type );
} }

View File

@ -612,7 +612,7 @@ private void throwLazyInitializationException(String message) {
throw new LazyInitializationException( throw new LazyInitializationException(
"failed to lazily initialize a collection" + "failed to lazily initialize a collection" +
(role == null ? "" : " of role: " + role) + (role == null ? "" : " of role: " + role) +
", " + message ": " + message
); );
} }
@ -698,7 +698,7 @@ else if ( this.session != null ) {
final String msg = generateUnexpectedSessionStateMessage( session ); final String msg = generateUnexpectedSessionStateMessage( session );
if ( isConnectedToSession() ) { if ( isConnectedToSession() ) {
throw new HibernateException( throw new HibernateException(
"Illegal attempt to associate a collection with two open sessions. " + msg "Illegal attempt to associate a collection with two open sessions: " + msg
); );
} }
else { else {
@ -783,7 +783,7 @@ public boolean needsRecreate(CollectionPersister persister) {
public final void forceInitialization() throws HibernateException { public final void forceInitialization() throws HibernateException {
if ( !initialized ) { if ( !initialized ) {
if ( initializing ) { if ( initializing ) {
throw new AssertionFailure( "force initialize loading collection" ); throw new AssertionFailure( "force initializing collection loading" );
} }
initialize( false ); initialize( false );
} }

View File

@ -103,7 +103,7 @@ public Session currentSession() throws HibernateException {
currentSession.close(); currentSession.close();
} }
catch ( Throwable ignore ) { catch ( Throwable ignore ) {
LOG.debug( "Unable to release generated current-session on failed synch registration", ignore ); LOG.debug( "Unable to release generated current-session on failed synchronization registration", ignore );
} }
throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" ); throw new HibernateException( "Unable to register cleanup Synchronization with TransactionManager" );
} }

View File

@ -63,7 +63,7 @@ public static OptimisticLockStyle interpretOldCode(int oldCode) {
return ALL; return ALL;
} }
default: { default: {
throw new IllegalArgumentException( "Illegal legacy optimistic lock style code :" + oldCode ); throw new IllegalArgumentException( "Illegal legacy optimistic lock style code : " + oldCode );
} }
} }
} }

View File

@ -192,7 +192,7 @@ private void checkNotAssociatedWithOtherPersistenceContextIfMutable(ManagedEntit
// NOTE: otherPersistenceContext may be operating on the entityEntry in a different thread. // NOTE: otherPersistenceContext may be operating on the entityEntry in a different thread.
// it is not safe to associate entityEntry with this EntityEntryContext. // it is not safe to associate entityEntry with this EntityEntryContext.
throw new HibernateException( throw new HibernateException(
"Illegal attempt to associate a ManagedEntity with two open persistence contexts. " + entityEntry "Illegal attempt to associate a ManagedEntity with two open persistence contexts: " + entityEntry
); );
} }
else { else {

View File

@ -162,7 +162,7 @@ protected EntityPersister locatePersisterForKey(EntityPersister persister) {
*/ */
protected void validateNaturalId(EntityPersister persister, Object[] naturalIdValues) { protected void validateNaturalId(EntityPersister persister, Object[] naturalIdValues) {
if ( !persister.hasNaturalIdentifier() ) { if ( !persister.hasNaturalIdentifier() ) {
throw new IllegalArgumentException( "Entity did not define a natrual-id" ); throw new IllegalArgumentException( "Entity did not define a natural-id" );
} }
if ( persister.getNaturalIdentifierProperties().length != naturalIdValues.length ) { if ( persister.getNaturalIdentifierProperties().length != naturalIdValues.length ) {
throw new IllegalArgumentException( "Mismatch between expected number of natural-id values and found." ); throw new IllegalArgumentException( "Mismatch between expected number of natural-id values and found." );

View File

@ -50,7 +50,7 @@ public static TypeNullability interpret(short code) {
return UNKNOWN; return UNKNOWN;
} }
default: { default: {
throw new IllegalArgumentException( "Unknown type nullability code [" + code + "] enountered" ); throw new IllegalArgumentException( "Unknown type nullability code [" + code + "] encountered" );
} }
} }
} }

View File

@ -58,7 +58,7 @@ public static TypeSearchability interpret(short code) {
return CHAR; return CHAR;
} }
default: { default: {
throw new IllegalArgumentException( "Unknown type searchability code [" + code + "] enountered" ); throw new IllegalArgumentException( "Unknown type searchability code [" + code + "] encountered" );
} }
} }
} }

View File

@ -342,8 +342,8 @@ public void validateParameters() throws QueryException {
final int values = positionalParameterValues == null ? 0 : positionalParameterValues.length; final int values = positionalParameterValues == null ? 0 : positionalParameterValues.length;
if ( types != values ) { if ( types != values ) {
throw new QueryException( throw new QueryException(
"Number of positional parameter types:" + types + "Number of positional parameter types [" + types +
" does not match number of positional parameters: " + values "] does not match number of positional parameters [" + values + "]"
); );
} }
} }

View File

@ -114,7 +114,7 @@ protected Object saveWithGeneratedId(
EntityPersister persister = source.getEntityPersister( entityName, entity ); EntityPersister persister = source.getEntityPersister( entityName, entity );
Object generatedId = persister.getIdentifierGenerator().generate( source, entity ); Object generatedId = persister.getIdentifierGenerator().generate( source, entity );
if ( generatedId == null ) { if ( generatedId == null ) {
throw new IdentifierGenerationException( "null id generated for:" + entity.getClass() ); throw new IdentifierGenerationException( "null id generated for: " + entity.getClass() );
} }
else if ( generatedId == IdentifierGeneratorHelper.SHORT_CIRCUIT_INDICATOR ) { else if ( generatedId == IdentifierGeneratorHelper.SHORT_CIRCUIT_INDICATOR ) {
return source.getIdentifier( entity ); return source.getIdentifier( entity );

View File

@ -65,7 +65,7 @@ public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
} }
} }
else { else {
LOG.trace( "Don't need to execute flush" ); LOG.trace( "No need to execute flush" );
event.setFlushRequired( false ); event.setFlushRequired( false );
actionQueue.clearFromFlushNeededCheck( oldSize ); actionQueue.clearFromFlushNeededCheck( oldSize );
} }

View File

@ -79,7 +79,7 @@ public void checkId(Object object, EntityPersister persister, Object id, Session
if ( !persister.getIdentifierType().isEqual( id, oid, session.getFactory() ) ) { if ( !persister.getIdentifierType().isEqual( id, oid, session.getFactory() ) ) {
throw new HibernateException( throw new HibernateException(
"identifier of an instance of " + persister.getEntityName() + " was altered from " "identifier of an instance of " + persister.getEntityName() + " was altered from "
+ id + " to " + oid + oid + " to " + id
); );
} }
} }
@ -283,7 +283,7 @@ else if ( !entry.isModifiableEntity() ) {
} }
else { else {
LOG.tracev( LOG.tracev(
"Updating deleted entity: ", "Updating deleted entity: {0}",
MessageHelper.infoString( persister, entry.getId(), session.getFactory() ) MessageHelper.infoString( persister, entry.getId(), session.getFactory() )
); );
} }

View File

@ -240,7 +240,7 @@ private void handleListenerAddition(T listener, Consumer<T> additionHandler) {
} }
case REPLACE_ORIGINAL: { case REPLACE_ORIGINAL: {
if ( debugEnabled ) { if ( debugEnabled ) {
log.debugf( "Replacing listener registration (%s) : `%s` -> %s", strategy.getAction(), existingListener, listener ); log.debugf( "Replacing listener registration (%s) : `%s` -> `%s`", strategy.getAction(), existingListener, listener );
} }
prepareListener( listener ); prepareListener( listener );

View File

@ -74,7 +74,7 @@ public Delegate(PostInsertIdentityPersister persister, Dialect dialect, String s
this.sequenceNextValFragment = dialect.getSelectSequenceNextValString( sequenceName ); this.sequenceNextValFragment = dialect.getSelectSequenceNextValString( sequenceName );
this.keyColumns = getPersister().getRootTableKeyColumnNames(); this.keyColumns = getPersister().getRootTableKeyColumnNames();
if ( keyColumns.length > 1 ) { if ( keyColumns.length > 1 ) {
throw new HibernateException( "sequence-identity generator cannot be used with with multi-column keys" ); throw new HibernateException( "sequence-identity generator cannot be used with multi-column keys" );
} }
} }

View File

@ -195,7 +195,7 @@ public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreation
} }
if ( sharedOptions.getPhysicalConnectionHandlingMode() != this.jdbcCoordinator.getLogicalConnection().getConnectionHandlingMode() ) { if ( sharedOptions.getPhysicalConnectionHandlingMode() != this.jdbcCoordinator.getLogicalConnection().getConnectionHandlingMode() ) {
log.debug( log.debug(
"Session creation specified 'PhysicalConnectionHandlingMode which is invalid in conjunction " + "Session creation specified 'PhysicalConnectionHandlingMode' which is invalid in conjunction " +
"with sharing JDBC connection between sessions; ignoring" "with sharing JDBC connection between sessions; ignoring"
); );
} }

View File

@ -665,7 +665,7 @@ private void errorIfResourceLocalDueToExplicitSynchronizationType() {
// 2) an explicit SynchronizationType is specified // 2) an explicit SynchronizationType is specified
if ( !getServiceRegistry().getService( TransactionCoordinatorBuilder.class ).isJta() ) { if ( !getServiceRegistry().getService( TransactionCoordinatorBuilder.class ).isJta() ) {
throw new IllegalStateException( throw new IllegalStateException(
"Illegal attempt to specify a SynchronizationType when building an EntityManager from a " + "Illegal attempt to specify a SynchronizationType when building an EntityManager from an " +
"EntityManagerFactory defined as RESOURCE_LOCAL (as opposed to JTA)" "EntityManagerFactory defined as RESOURCE_LOCAL (as opposed to JTA)"
); );
} }
@ -879,7 +879,7 @@ public void addNamedQuery(String name, Query query) {
// if we get here, we are unsure how to properly unwrap the incoming query to extract the needed information // if we get here, we are unsure how to properly unwrap the incoming query to extract the needed information
throw new PersistenceException( throw new PersistenceException(
String.format( String.format(
"Unsure how to how to properly unwrap given Query [%s] as basis for named query", "Unsure how to properly unwrap given Query [%s] as basis for named query",
query query
) )
); );

View File

@ -78,7 +78,7 @@ private Object copyListeners() {
); );
} }
catch (Throwable t) { catch (Throwable t) {
throw new HibernateException( "Unable copy copy listener [" + pd.getName() + "]" ); throw new HibernateException( "Unable to copy listener [" + pd.getName() + "]" );
} }
} }
} }

View File

@ -71,7 +71,7 @@ else if ( systemId.startsWith( USER_NAMESPACE ) ) {
LOG.debugf( "Unable to locate [%s] on classpath", systemId ); LOG.debugf( "Unable to locate [%s] on classpath", systemId );
} }
else { else {
LOG.debugf( "Located [%s] in classpath", systemId ); LOG.debugf( "Located [%s] on classpath", systemId );
source = new InputSource( stream ); source = new InputSource( stream );
source.setPublicId( publicId ); source.setPublicId( publicId );
source.setSystemId( systemId ); source.setSystemId( systemId );
@ -92,7 +92,7 @@ private InputSource resolveOnClassPath(String publicId, String systemId, String
} }
} }
else { else {
LOG.debugf( "Located [%s] in classpath", systemId ); LOG.debugf( "Located [%s] on classpath", systemId );
source = new InputSource( dtdStream ); source = new InputSource( dtdStream );
source.setPublicId( publicId ); source.setPublicId( publicId );
source.setSystemId( systemId ); source.setSystemId( systemId );

View File

@ -145,7 +145,7 @@ public void registerService(Manageable service, Class<? extends Service> service
registerMBean( objectName, service.getManagementBean() ); registerMBean( objectName, service.getManagementBean() );
} }
catch ( MalformedObjectNameException e ) { catch ( MalformedObjectNameException e ) {
throw new HibernateException( "Unable to generate service IbjectName", e ); throw new HibernateException( "Unable to generate service ObjectName", e );
} }
} }

View File

@ -160,7 +160,7 @@ private Object processCachedEntry(
if ( entry.isReferenceEntry() ) { if ( entry.isReferenceEntry() ) {
if ( event.getInstanceToLoad() != null ) { if ( event.getInstanceToLoad() != null ) {
throw new HibernateException( throw new HibernateException(
"Attempt to load entity [%s] from cache using provided object instance, but cache " + "Attempt to load entity from cache using provided object instance, but cache " +
"is storing references: " + event.getEntityId() ); "is storing references: " + event.getEntityId() );
} }
else { else {

View File

@ -182,7 +182,7 @@ public void addSubclass(Subclass subclass) throws MappingException {
throw new MappingException( throw new MappingException(
"Circular inheritance mapping detected: " + "Circular inheritance mapping detected: " +
subclass.getEntityName() + subclass.getEntityName() +
" will have it self as superclass when extending " + " will have itself as superclass when extending " +
getEntityName() getEntityName()
); );
} }

View File

@ -185,7 +185,7 @@ public <X, Y> SingularPersistentAttribute<X, Y> buildIdAttribute(
public <X, Y> SingularAttributeImpl<X, Y> buildVersionAttribute( public <X, Y> SingularAttributeImpl<X, Y> buildVersionAttribute(
IdentifiableDomainType<X> ownerType, IdentifiableDomainType<X> ownerType,
Property property) { Property property) {
LOG.trace( "Building version attribute [ownerType.getTypeName()" + "." + "property.getName()]" ); LOG.trace( "Building version attribute [" + ownerType.getTypeName() + "." + property.getName() + "]" );
final SingularAttributeMetadata<X, Y> attributeMetadata = (SingularAttributeMetadata<X, Y>) determineAttributeMetadata( final SingularAttributeMetadata<X, Y> attributeMetadata = (SingularAttributeMetadata<X, Y>) determineAttributeMetadata(
wrap( ownerType, property ), wrap( ownerType, property ),

View File

@ -309,7 +309,7 @@ private String resolveImportedName(String name) {
private void applyNamedEntityGraphs(java.util.Collection<NamedEntityGraphDefinition> namedEntityGraphs) { private void applyNamedEntityGraphs(java.util.Collection<NamedEntityGraphDefinition> namedEntityGraphs) {
for ( NamedEntityGraphDefinition definition : namedEntityGraphs ) { for ( NamedEntityGraphDefinition definition : namedEntityGraphs ) {
log.debugf( log.debugf(
"Applying named entity graph [name=%s, entity-name=%s, jpa-entity-name=%s", "Applying named entity graph [name=%s, entity-name=%s, jpa-entity-name=%s]",
definition.getRegisteredName(), definition.getRegisteredName(),
definition.getEntityName(), definition.getEntityName(),
definition.getJpaEntityName() definition.getJpaEntityName()

View File

@ -47,7 +47,7 @@ public String[] toColumns(String alias, String propertyName) throws QueryExcepti
* Given a property path, return the corresponding column name(s). * Given a property path, return the corresponding column name(s).
*/ */
public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException { public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException {
throw new UnsupportedOperationException( "References to collections must be define a SQL alias" ); throw new UnsupportedOperationException( "References to collections must define an SQL alias" );
} }
public Type getType() { public Type getType() {

View File

@ -236,7 +236,7 @@ else if ( session.isOpenOrWaitingForAutoClose() && session.isConnected() ) {
checkTargetState(session); checkTargetState(session);
} }
else { else {
throw new LazyInitializationException( "could not initialize proxy [" + entityName + "#" + id + "] - Session was closed or disced" ); throw new LazyInitializationException( "could not initialize proxy [" + entityName + "#" + id + "] - Session was closed or disconnected" );
} }
} }

View File

@ -51,7 +51,7 @@ else if ( mode instanceof String ) {
} }
throw new HibernateException( throw new HibernateException(
"Unrecognized immutable_entity_update_query_handling_mode value : " + mode "Unrecognized immutable_entity_update_query_handling_mode value : " + mode
+ ". Supported values include 'warning' and 'exception''." + ". Supported values include 'warning' and 'exception'."
); );
} }
} }

View File

@ -96,7 +96,7 @@ public void initialize() {
throw e; throw e;
} }
catch (Exception e) { catch (Exception e) {
log.debugf( "Error resolving CDI bean [%s] - using fallback" ); log.debugf( "Error resolving CDI bean - using fallback" );
this.beanInstance = produceFallbackInstance(); this.beanInstance = produceFallbackInstance();
this.instance = null; this.instance = null;
} }

View File

@ -167,7 +167,7 @@ public Output getOutput() {
protected Output buildOutput() { protected Output buildOutput() {
if ( log.isDebugEnabled() ) { if ( log.isDebugEnabled() ) {
log.debugf( log.debugf(
"Building Return [isResultSet=%s, updateCount=%s, extendedReturn=%s", "Building Return [isResultSet=%s, updateCount=%s, extendedReturn=%s]",
isResultSet(), isResultSet(),
getUpdateCount(), getUpdateCount(),
hasExtendedReturns() hasExtendedReturns()

View File

@ -24,7 +24,7 @@ public boolean[] includeInTransform(String[] aliases, int tupleLength) {
if ( aliases.length != tupleLength ) { if ( aliases.length != tupleLength ) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"aliases and tupleLength must have the same length; " + "aliases and tupleLength must have the same length; " +
"aliases.length=" + aliases.length + "tupleLength=" + tupleLength "aliases.length=" + aliases.length + "; tupleLength=" + tupleLength
); );
} }
boolean[] includeInTransform = new boolean[tupleLength]; boolean[] includeInTransform = new boolean[tupleLength];

View File

@ -97,8 +97,8 @@ private static CacheableResultTransformer create(
int tupleLength = ArrayHelper.countTrue( includeInTuple ); int tupleLength = ArrayHelper.countTrue( includeInTuple );
if ( aliases != null && aliases.length != tupleLength ) { if ( aliases != null && aliases.length != tupleLength ) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"if aliases is not null, then the length of aliases[] must equal the number of true elements in includeInTuple; " + "if aliases are not null, then the length of aliases must equal the number of true elements in includeInTuple; " +
"aliases.length=" + aliases.length + "tupleLength=" + tupleLength "aliases.length=" + aliases.length + "; tupleLength=" + tupleLength
); );
} }
return new CacheableResultTransformer( return new CacheableResultTransformer(

View File

@ -61,7 +61,7 @@ public void testCascadeFromDetachedToNonDirtyRepresentations() {
em.getTransaction().begin(); em.getTransaction().begin();
try { try {
em.merge( hoarder ); em.merge( hoarder );
fail( "should have failed due IllegalStateException"); fail( "should have failed due to IllegalStateException");
} }
catch (IllegalStateException ex) { catch (IllegalStateException ex) {
//expected //expected
@ -106,7 +106,7 @@ public void testTopLevelManyToOneManagedNestedIsDetached() {
// now item1Merged is managed and it has a nested detached item // now item1Merged is managed and it has a nested detached item
try { try {
em.merge( item1Merged ); em.merge( item1Merged );
fail( "should have failed due IllegalStateException"); fail( "should have failed due to IllegalStateException");
} }
catch (IllegalStateException ex) { catch (IllegalStateException ex) {
//expected //expected

View File

@ -77,7 +77,7 @@ public static void writeFile(MetaEntity entity, Context context) {
catch ( IOException ioEx ) { catch ( IOException ioEx ) {
context.logMessage( context.logMessage(
Diagnostic.Kind.ERROR, Diagnostic.Kind.ERROR,
"Problem opening file to write MetaModel for " + entity.getSimpleName() + ioEx.getMessage() "Problem opening file to write MetaModel for " + entity.getSimpleName() + ": " + ioEx.getMessage()
); );
} }
} }