Author: epbernard
Date: 2008-05-17 08:49:38 -0400 (Sat, 17 May 2008)
New Revision: 14671
Modified:
annotations/trunk/ivy.xml
annotations/trunk/pom.xml
annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java
annotations/trunk/src/java/org/hibernate/cfg/AnnotationConfiguration.java
annotations/trunk/src/java/org/hibernate/cfg/BinderHelper.java
annotations/trunk/src/java/org/hibernate/cfg/EJB3DTDEntityResolver.java
annotations/trunk/src/java/org/hibernate/cfg/Ejb3Column.java
annotations/trunk/src/java/org/hibernate/cfg/ExtendedMappings.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/ListBinder.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/QueryBinder.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/SetBinder.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/TableBinder.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/Version.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/XMLContext.java
annotations/trunk/src/java/org/hibernate/cfg/search/SearchConfiguration.java
annotations/trunk/src/java/org/hibernate/type/EnumType.java
annotations/trunk/src/test/org/hibernate/test/annotations/reflection/LogListener.java
annotations/trunk/src/test/org/hibernate/test/annotations/reflection/OtherLogListener.java
Log:
ANN-741 move to slf4j
Modified: annotations/trunk/ivy.xml
===================================================================
--- annotations/trunk/ivy.xml 2008-05-17 12:47:32 UTC (rev 14670)
+++ annotations/trunk/ivy.xml 2008-05-17 12:49:38 UTC (rev 14671)
@@ -16,11 +16,11 @@
<dependency name="ejb3-persistence" rev="1.0.2.GA"
conf="default->default"/>
<dependency name="commons-annotations" rev="latest"
conf="default->default"/>
<dependency org="org.hibernate" name="hibernate-core"
rev="3.3.0.CR1" conf="default->default"/>
- <dependency org="commons-logging" name="commons-logging"
rev="1.0.4" conf="default->default"/>
<dependency org="dom4j" name="dom4j" rev="1.6.1"
conf="default->default"/>
+ <dependency org="org.slf4j" name="slf4j-api"
rev="1.4.2" conf="default->default"/>
+
<!-- transitive dependencies -->
- <dependency org="org.slf4j" name="slf4j-api"
rev="1.4.2" conf="test->default"/>
<dependency org="antlr" name="antlr" rev="2.7.6"
conf="test->default"/>
<dependency org="commons-collections"
name="commons-collections" rev="3.1"
conf="test->default"/>
Modified: annotations/trunk/pom.xml
===================================================================
--- annotations/trunk/pom.xml 2008-05-17 12:47:32 UTC (rev 14670)
+++ annotations/trunk/pom.xml 2008-05-17 12:49:38 UTC (rev 14671)
@@ -38,10 +38,10 @@
<version>3.3.0.CR1</version>
</dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- </dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.4.2</version>
+ </dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
Modified: annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java 2008-05-17 12:47:32
UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java 2008-05-17 12:49:38
UTC (rev 14671)
@@ -49,8 +49,6 @@
import javax.persistence.Transient;
import javax.persistence.Version;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.EntityMode;
@@ -135,6 +133,8 @@
import org.hibernate.persister.entity.UnionSubclassEntityPersister;
import org.hibernate.type.TypeFactory;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* JSR 175 annotation binder
@@ -165,7 +165,7 @@
private AnnotationBinder() {
}
- private static final Log log = LogFactory.getLog( AnnotationBinder.class );
+ private static final Logger log = LoggerFactory.getLogger( AnnotationBinder.class );
public static void bindDefaults(ExtendedMappings mappings) {
Map defaults = mappings.getReflectionManager().getDefaults();
@@ -219,14 +219,14 @@
pckg = mappings.getReflectionManager().packageForName( packageName );
}
catch (ClassNotFoundException cnf) {
- log.warn( "Package not found or wo package-info.java: " + packageName );
+ log.warn( "Package not found or wo package-info.java: {}", packageName );
return;
}
if ( pckg.isAnnotationPresent( SequenceGenerator.class ) ) {
SequenceGenerator ann = pckg.getAnnotation( SequenceGenerator.class );
IdGenerator idGen = buildIdGenerator( ann, mappings );
mappings.addGenerator( idGen );
- log.debug( "Add sequence generator with name: " + idGen.getName() );
+ log.debug( "Add sequence generator with name: {}", idGen.getName() );
}
if ( pckg.isAnnotationPresent( TableGenerator.class ) ) {
TableGenerator ann = pckg.getAnnotation( TableGenerator.class );
@@ -351,7 +351,7 @@
idGen.addParam( MultipleHiLoPerTableGenerator.PK_VALUE_NAME, tabGen.pkColumnValue()
);
}
idGen.addParam( TableHiLoGenerator.MAX_LO, String.valueOf( tabGen.allocationSize() - 1
) );
- log.debug( "Add table generator with name: " + idGen.getName() );
+ log.debug( "Add table generator with name: {}", idGen.getName() );
}
else if ( ann instanceof SequenceGenerator ) {
SequenceGenerator seqGen = (SequenceGenerator) ann;
@@ -368,7 +368,7 @@
);
}
idGen.addParam( SequenceHiLoGenerator.MAX_LO, String.valueOf( seqGen.allocationSize()
- 1 ) );
- log.debug( "Add sequence generator with name: " + idGen.getName() );
+ log.debug( "Add sequence generator with name: {}", idGen.getName() );
}
else if ( ann instanceof GenericGenerator ) {
GenericGenerator genGen = (GenericGenerator) ann;
@@ -378,7 +378,7 @@
for (Parameter parameter : params) {
idGen.addParam( parameter.name(), parameter.value() );
}
- log.debug( "Add generic generator with name: " + idGen.getName() );
+ log.debug( "Add generic generator with name: {}", idGen.getName() );
}
else {
throw new AssertionFailure( "Unknown Generator annotation: " + ann );
@@ -403,7 +403,7 @@
if ( AnnotatedClassType.NONE.equals( classType )
&& clazzToProcess.isAnnotationPresent(
org.hibernate.annotations.Entity.class ) ) {
log.warn( "Class annotated @org.hibernate.annotations.Entity but not
javax.persistence.Entity "
- + "(most likely a user error): " + clazzToProcess.getName() );
+ + "(most likely a user error): {}", clazzToProcess.getName() );
}
return;
}
@@ -415,7 +415,7 @@
);
}
XAnnotatedElement annotatedClass = clazzToProcess;
- if ( log.isInfoEnabled() ) log.info( "Binding entity from annotated class: "
+ clazzToProcess.getName() );
+ log.info( "Binding entity from annotated class: {}", clazzToProcess.getName()
);
InheritanceState superEntityState =
InheritanceState.getSuperEntityInheritanceState(
clazzToProcess, inheritanceStatePerClass, mappings.getReflectionManager()
@@ -507,8 +507,8 @@
}
if ( discAnn != null && inheritanceState.hasParents ) {
log.warn(
- "Discriminator column has to be defined in the root entity, it will be ignored
in subclass: "
- + clazzToProcess.getName()
+ "Discriminator column has to be defined in the root entity, it will be ignored
in subclass: {}",
+ clazzToProcess.getName()
);
}
discrimValue = annotatedClass.isAnnotationPresent( DiscriminatorValue.class ) ?
@@ -655,7 +655,7 @@
}
if ( onDeleteAnn != null && !onDeleteAppropriate ) {
log.warn(
- "Inapropriate use of @OnDelete on entity, annotation ignored: " +
propertyHolder.getEntityName()
+ "Inapropriate use of @OnDelete on entity, annotation ignored: {}",
propertyHolder.getEntityName()
);
}
@@ -944,7 +944,7 @@
params.put( param.name(), TypeFactory.heuristicType( param.type() ) );
}
FilterDefinition def = new FilterDefinition( defAnn.name(), defAnn.defaultCondition(),
params );
- if ( log.isInfoEnabled() ) log.info( "Binding filter definition: " +
def.getFilterName() );
+ log.info( "Binding filter definition: {}", def.getFilterName() );
mappings.addFilterDefinition( def );
}
@@ -966,7 +966,7 @@
for (Parameter param : defAnn.parameters()) {
params.setProperty( param.name(), param.value() );
}
- if ( log.isInfoEnabled() ) log.info( "Binding type definition: " +
defAnn.name() );
+ log.info( "Binding type definition: {}", defAnn.name() );
mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params );
}
@@ -986,7 +986,7 @@
discriminatorColumn.linkWithValue( discrim );
discrim.setTypeName( discriminatorColumn.getDiscriminatorTypeName() );
rootClass.setPolymorphic( true );
- log.debug( "Setting discriminator for entity " + rootClass.getEntityName()
);
+ log.debug( "Setting discriminator for entity {}", rootClass.getEntityName()
);
}
}
@@ -1019,7 +1019,7 @@
}
}
- log.debug( "Processing " + propertyHolder.getEntityName() + " " +
accessType + " annotation" );
+ log.debug( "Processing {} {} annotation", propertyHolder.getEntityName(),
accessType );
List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
//order so that property are used in the same order when binding native query
Collections.sort( properties, new Comparator<XProperty>() {
@@ -1130,11 +1130,9 @@
*/
Ejb3Column[] columns = null;
Ejb3JoinColumn[] joinColumns = null;
- if ( log.isDebugEnabled() ) {
- log.debug(
- "Processing annotations of " + propertyHolder.getEntityName() +
"." + inferredData.getPropertyName()
- );
- }
+ log.debug(
+ "Processing annotations of {}.{}", propertyHolder.getEntityName(),
inferredData.getPropertyName()
+ );
if ( property.isAnnotationPresent( Parent.class ) ) {
if ( propertyHolder.isComponent() ) {
@@ -1256,7 +1254,7 @@
"@IdClass class should not have @Id nor @EmbeddedId properties"
);
}
- log.debug( inferredData.getPropertyName() + " is an id" );
+ log.debug( "{} is an id", inferredData.getPropertyName() );
//clone classGenerator and override with local values
HashMap<String, IdGenerator> localGenerators = (HashMap<String,
IdGenerator>) classGenerators.clone();
localGenerators.putAll( buildLocalGenerators( property, mappings ) );
@@ -1292,13 +1290,9 @@
false,
isIdentifierMapper, mappings
);
- if ( log.isDebugEnabled() ) {
- log.debug(
- "Bind " + ( isComponent ?
- "@EmbeddedId" :
- "@Id" ) + " on " + inferredData.getPropertyName()
- );
- }
+ log.debug(
+ "Bind {} on {}", ( isComponent ? "@EmbeddedId" : "@Id"
), inferredData.getPropertyName()
+ );
}
else if ( property.isAnnotationPresent( Version.class ) ) {
if ( isIdentifierMapper ) {
@@ -1318,7 +1312,7 @@
+ propertyHolder.getEntityName()
);
}
- log.debug( inferredData.getPropertyName() + " is a version property" );
+ log.debug( "{} is a version property", inferredData.getPropertyName() );
RootClass rootClass = (RootClass) propertyHolder.getPersistentClass();
PropertyBinder propBinder = new PropertyBinder();
propBinder.setName( inferredData.getPropertyName() );
@@ -1338,9 +1332,8 @@
simpleValue.setNullValue( "undefined" );
rootClass.setOptimisticLockMode( Versioning.OPTIMISTIC_LOCK_VERSION );
log.debug(
- "Version name: " + rootClass.getVersion().getName() + ",
unsavedValue: " + ( (SimpleValue) rootClass
- .getVersion()
- .getValue() ).getNullValue()
+ "Version name: {}, unsavedValue: {}", rootClass.getVersion().getName(),
+ ( (SimpleValue) rootClass.getVersion().getValue() ).getNullValue()
);
}
else if ( property.isAnnotationPresent( ManyToOne.class ) ) {
@@ -1812,7 +1805,7 @@
}
comp.setNodeName( inferredData.getPropertyName() );
String subpath = StringHelper.qualify( propertyHolder.getPath(),
inferredData.getPropertyName() );
- log.debug( "Binding component with path: " + subpath );
+ log.debug( "Binding component with path: {}", subpath );
PropertyHolder subHolder = PropertyHolderBuilder.buildPropertyHolder(
comp, subpath,
inferredData, propertyHolder, mappings
@@ -2066,7 +2059,7 @@
) {
//column.getTable() => persistentClass.getTable()
final String propertyName = inferredData.getPropertyName();
- log.debug( "Fetching " + propertyName + " with " + fetchMode );
+ log.debug( "Fetching {} with {}", propertyName, fetchMode );
boolean mapToPK = true;
if ( !trueOneToOne ) {
//try to find a hidden true one to one (FK == PK columns)
@@ -2313,8 +2306,8 @@
final boolean mixingStrategy = state.type != null && !state.type.equals(
superclassState.type );
if ( nonDefault && mixingStrategy ) {
log.warn(
- "Mixing inheritance strategy in a entity hierarchy is not allowed, ignoring
sub strategy in: " + clazz
- .getName()
+ "Mixing inheritance strategy in a entity hierarchy is not allowed, ignoring
sub strategy in: {}",
+ clazz.getName()
);
}
state.type = superclassState.type;
Modified: annotations/trunk/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2008-05-17
12:47:32 UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -6,6 +6,7 @@
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
@@ -20,13 +21,9 @@
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TreeSet;
-import java.net.URL;
-
import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.DocumentException;
@@ -34,21 +31,17 @@
import org.dom4j.io.SAXReader;
import org.hibernate.AnnotationException;
import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
-import org.hibernate.Interceptor;
import org.hibernate.annotations.AnyMetaDef;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.cfg.annotations.Version;
import org.hibernate.cfg.annotations.reflection.EJB3ReflectionManager;
import org.hibernate.cfg.search.SearchConfiguration;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.event.PreInsertEventListener;
import org.hibernate.event.PreUpdateEventListener;
-import org.hibernate.event.EventListeners;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
@@ -59,6 +52,8 @@
import org.hibernate.util.StringHelper;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Similar to the {@link Configuration} object but handles EJB3 and Hibernate
@@ -67,7 +62,7 @@
* @author Emmanuel Bernard
*/
public class AnnotationConfiguration extends Configuration {
- private static Log log = LogFactory.getLog( AnnotationConfiguration.class );
+ private Logger log = LoggerFactory.getLogger( AnnotationConfiguration.class );
static {
Version.touch(); //touch version
@@ -167,7 +162,7 @@
* @return the configuration object
*/
public AnnotationConfiguration addPackage(String packageName) throws MappingException {
- log.info( "Mapping package " + packageName );
+ log.info( "Mapping package {}", packageName );
try {
AnnotationBinder.bindPackage( packageName, createExtendedMappings() );
return this;
@@ -537,7 +532,7 @@
annotatedClassEntities.clear();
}
else {
- log.warn( "Unknown artifact: " + artifact );
+ log.warn( "Unknown artifact: {}", artifact );
}
}
@@ -613,24 +608,24 @@
Attribute pckg = subelement.attribute( "package" );
Attribute clazz = subelement.attribute( "class" );
if ( rsrc != null ) {
- log.debug( name + "<-" + rsrc );
+ log.debug( "{} <- {}", name, rsrc );
addResource( rsrc.getValue() );
}
else if ( jar != null ) {
- log.debug( name + "<-" + jar );
+ log.debug( "{} <- {}", name, jar );
addJar( new File( jar.getValue() ) );
}
else if ( file != null ) {
- log.debug( name + "<-" + file );
+ log.debug( "{} <- {}", name, file );
addFile( file.getValue() );
}
else if ( pckg != null ) {
- log.debug( name + "<-" + pckg );
+ log.debug( "{} <- {}", name, pckg );
addPackage( pckg.getValue() );
}
else if ( clazz != null ) {
- log.debug( name + "<-" + clazz );
- Class loadedClass = null;
+ log.debug( "{} <- {}", name, clazz );
+ Class loadedClass;
try {
loadedClass = ReflectHelper.classForName( clazz.getValue() );
}
Modified: annotations/trunk/src/java/org/hibernate/cfg/BinderHelper.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/BinderHelper.java 2008-05-17 12:47:32 UTC
(rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/BinderHelper.java 2008-05-17 12:49:38 UTC
(rev 14671)
@@ -12,8 +12,6 @@
import java.util.Set;
import java.util.StringTokenizer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
@@ -42,6 +40,8 @@
import org.hibernate.mapping.Value;
import org.hibernate.type.TypeFactory;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Emmanuel Bernard
@@ -49,7 +49,7 @@
public class BinderHelper {
public static final String ANNOTATION_STRING_DEFAULT = "";
- private static Log log = LogFactory.getLog( BinderHelper.class );
+ private static Logger log = LoggerFactory.getLogger( BinderHelper.class );
private BinderHelper() {
}
@@ -550,7 +550,7 @@
private static void bindAnyMetaDef(AnyMetaDef defAnn, ExtendedMappings mappings) {
if ( isDefault( defAnn.name() ) ) return; //don't map not named definitions
- if ( log.isInfoEnabled() ) log.info( "Binding Any Meta definition: " +
defAnn.name() );
+ log.info( "Binding Any Meta definition: {}", defAnn.name() );
mappings.addAnyMetaDef( defAnn );
}
}
Modified: annotations/trunk/src/java/org/hibernate/cfg/EJB3DTDEntityResolver.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/EJB3DTDEntityResolver.java 2008-05-17
12:47:32 UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/EJB3DTDEntityResolver.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -3,11 +3,11 @@
import java.io.InputStream;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.util.DTDEntityResolver;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Emmanuel Bernard
@@ -15,7 +15,7 @@
public class EJB3DTDEntityResolver extends DTDEntityResolver {
public static final EntityResolver INSTANCE = new EJB3DTDEntityResolver();
- private static final Log log = LogFactory.getLog( EJB3DTDEntityResolver.class );
+ private final Logger log = LoggerFactory.getLogger( EJB3DTDEntityResolver.class );
boolean resolved = false;
@@ -34,10 +34,10 @@
String path = "org/hibernate/ejb/" + "orm_1_0.xsd";
InputStream dtdStream = resolveInHibernateNamespace( path );
if ( dtdStream == null ) {
- log.debug( "unable to locate [" + systemId + "] on classpath"
);
+ log.debug( "unable to locate [{}] on classpath", systemId );
}
else {
- log.debug( "located [" + systemId + "] in classpath" );
+ log.debug( "located [{}] in classpath", systemId );
InputSource source = new InputSource( dtdStream );
source.setPublicId( publicId );
source.setSystemId( systemId );
@@ -52,10 +52,10 @@
String path = "org/hibernate/ejb/" + "persistence_1_0.xsd";
InputStream dtdStream = resolveInHibernateNamespace( path );
if ( dtdStream == null ) {
- log.debug( "unable to locate [" + systemId + "] on classpath"
);
+ log.debug( "unable to locate [{}] on classpath", systemId );
}
else {
- log.debug( "located [" + systemId + "] in classpath" );
+ log.debug( "located [{}] in classpath", systemId );
InputSource source = new InputSource( dtdStream );
source.setPublicId( publicId );
source.setSystemId( systemId );
Modified: annotations/trunk/src/java/org/hibernate/cfg/Ejb3Column.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/Ejb3Column.java 2008-05-17 12:47:32 UTC
(rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/Ejb3Column.java 2008-05-17 12:49:38 UTC
(rev 14671)
@@ -3,8 +3,6 @@
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.Index;
@@ -15,6 +13,8 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.util.StringHelper;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
/**
* Wrap state of an EJB3 @Column annotation
@@ -23,7 +23,7 @@
* @author Emmanuel Bernard
*/
public class Ejb3Column {
- private static final Log log = LogFactory.getLog( Ejb3Column.class );
+ private static final Logger log = LoggerFactory.getLogger( Ejb3Column.class );
private Column mappingColumn;
private boolean insertable = true;
private boolean updatable = true;
@@ -150,7 +150,7 @@
public void bind() {
if ( StringHelper.isNotEmpty( formulaString ) ) {
- log.debug( "binding formula " + formulaString );
+ log.debug( "binding formula {}", formulaString );
formula = new Formula();
formula.setFormula( formulaString );
}
@@ -158,7 +158,7 @@
initMappingColumn(
logicalColumnName, propertyName, length, precision, scale, nullable, sqlType,
unique, true
);
- log.debug( "Binding column " + mappingColumn.getName() + " unique
" + unique );
+ log.debug( "Binding column {}. Unique {}", mappingColumn.getName(), unique
);
}
}
@@ -336,7 +336,7 @@
throw new AnnotationException( "AttributeOverride.column() should override all
columns for now" );
}
actualCols = overriddenCols.length == 0 ? null : overriddenCols;
- log.debug( "Column(s) overridden for property " +
inferredData.getPropertyName() );
+ log.debug( "Column(s) overridden for property {}",
inferredData.getPropertyName() );
}
if ( actualCols == null ) {
columns = buildImplicitColumn( inferredData, secondaryTables, propertyHolder,
nullability, mappings );
Modified: annotations/trunk/src/java/org/hibernate/cfg/ExtendedMappings.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/ExtendedMappings.java 2008-05-17 12:47:32
UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/ExtendedMappings.java 2008-05-17 12:49:38
UTC (rev 14671)
@@ -10,8 +10,6 @@
import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.AnyMetaDef;
@@ -24,6 +22,8 @@
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
/**
* Allow annotation related mappings
@@ -34,7 +34,7 @@
*/
public class ExtendedMappings extends Mappings {
- private static final Log log = LogFactory.getLog( ExtendedMappings.class );
+ private final Logger log = LoggerFactory.getLogger( ExtendedMappings.class );
private final Map<String, IdGenerator> namedGenerators;
private final Map<String, Map<String, Join>> joins;
@@ -102,13 +102,13 @@
public void addGenerator(IdGenerator generator) throws MappingException {
if ( !defaultNamedGenerators.contains( generator.getName() ) ) {
Object old = namedGenerators.put( generator.getName(), generator );
- if ( old != null ) log.warn( "duplicate generator name: " +
generator.getName() );
+ if ( old != null ) log.warn( "duplicate generator name: {}",
generator.getName() );
}
}
public void addJoins(PersistentClass persistentClass, Map<String, Join> joins)
throws MappingException {
Object old = this.joins.put( persistentClass.getEntityName(), joins );
- if ( old != null ) log.warn( "duplicate joins for class: " +
persistentClass.getEntityName() );
+ if ( old != null ) log.warn( "duplicate joins for class: {}",
persistentClass.getEntityName() );
}
public AnnotatedClassType addClassType(XClass clazz) {
@@ -169,7 +169,7 @@
public void addGeneratorTable(String name, Properties params) {
Object old = generatorTables.put( name, params );
- if ( old != null ) log.warn( "duplicate generator table: " + name );
+ if ( old != null ) log.warn( "duplicate generator table: {}", name );
}
public Properties getGeneratorTableProperties(String name, Map<String, Properties>
localGeneratorTables) {
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
---
annotations/trunk/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/java/org/hibernate/cfg/annotations/CollectionBinder.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -16,8 +16,6 @@
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
@@ -81,6 +79,8 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Collection binder
@@ -90,7 +90,7 @@
*/
public abstract class CollectionBinder {
- private static final Log log = LogFactory.getLog( CollectionBinder.class );
+ private Logger log = LoggerFactory.getLogger( CollectionBinder.class );
protected Collection collection;
protected String propertyName;
@@ -307,7 +307,7 @@
public void bind() {
this.collection = createCollection( propertyHolder.getPersistentClass() );
- log.debug( "Collection role: " + StringHelper.qualify(
propertyHolder.getPath(), propertyName ) );
+ log.debug( "Collection role: {}", StringHelper.qualify(
propertyHolder.getPath(), propertyName ) );
collection.setRole( StringHelper.qualify( propertyHolder.getPath(), propertyName ) );
collection.setNodeName( propertyName );
@@ -617,11 +617,8 @@
XClass collectionType,
boolean cascadeDeleteEnabled, boolean ignoreNotFound, String hqlOrderBy,
ExtendedMappings extendedMappings
) {
- if ( log.isDebugEnabled() ) {
- log.debug(
- "Binding a OneToMany: " + propertyHolder.getEntityName() + "." +
propertyName + " through a foreign key"
- );
- }
+
+ log.debug("Binding a OneToMany: {}.{} through a foreign key",
propertyHolder.getEntityName(), propertyName);
org.hibernate.mapping.OneToMany oneToMany = new org.hibernate.mapping.OneToMany(
collection.getOwner() );
collection.setElement( oneToMany );
oneToMany.setReferencedEntityName( collectionType.getName() );
@@ -1049,16 +1046,16 @@
if ( log.isDebugEnabled() ) {
String path = collValue.getOwnerEntityName() + "." +
joinColumns[0].getPropertyName();
if ( isCollectionOfEntities && unique ) {
- log.debug( "Binding a OneToMany: " + path + " through an association
table" );
+ log.debug( "Binding a OneToMany: {} through an association table", path );
}
else if ( isCollectionOfEntities ) {
- log.debug( "Binding as ManyToMany: " + path );
+ log.debug( "Binding as ManyToMany: {}", path );
}
else if ( anyAnn != null ) {
- log.debug( "Binding a ManyToAny: " + path );
+ log.debug( "Binding a ManyToAny: {}", path );
}
else {
- log.debug( "Binding a collection of element: " + path );
+ log.debug( "Binding a collection of element: {}", path );
}
}
//check for user error
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2008-05-17
12:47:32 UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -14,8 +14,6 @@
import javax.persistence.SecondaryTables;
import javax.persistence.UniqueConstraint;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.EntityMode;
@@ -61,6 +59,8 @@
import org.hibernate.mapping.Value;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Stateful holder and processor for binding Entity information
@@ -72,7 +72,7 @@
private XClass annotatedClass;
private PersistentClass persistentClass;
private ExtendedMappings mappings;
- private static Log log = LogFactory.getLog( EntityBinder.class );
+ private Logger log = LoggerFactory.getLogger( EntityBinder.class );
private String discriminatorValue = "";
private boolean isPropertyAnnotated = false;
private boolean dynamicInsert;
@@ -192,12 +192,12 @@
}
else {
if ( explicitHibernateEntityAnnotation ) {
- log.warn( "(a)org.hibernate.annotations.Entity used on a non root entity: ignored
for "
- + annotatedClass.getName() );
+ log.warn( "(a)org.hibernate.annotations.Entity used on a non root entity: ignored
for {}",
+ annotatedClass.getName() );
}
if ( annotatedClass.isAnnotationPresent( Immutable.class ) ) {
- log.warn( "@Immutable used on a non root entity: ignored for "
- + annotatedClass.getName() );
+ log.warn( "@Immutable used on a non root entity: ignored for {}",
+ annotatedClass.getName() );
}
}
persistentClass.setOptimisticLockMode( getVersioning( optimisticLockType ) );
@@ -289,10 +289,10 @@
}
else {
if ( filters.size() > 0 ) {
- log.warn( "@Filter not allowed on subclasses (ignored): " +
persistentClass.getEntityName() );
+ log.warn( "@Filter not allowed on subclasses (ignored): {}",
persistentClass.getEntityName() );
}
}
- log.debug( "Import with entity name=" + name );
+ log.debug( "Import with entity name {}", name );
try {
mappings.addImport( persistentClass.getEntityName(), name );
String entityName = persistentClass.getEntityName();
@@ -419,9 +419,7 @@
);
if ( persistentClass instanceof TableOwner ) {
- if ( log.isInfoEnabled() ) {
- log.info( "Bind entity " + persistentClass.getEntityName() + " on
table " + table.getName() );
- }
+ log.info( "Bind entity {} on table {}", persistentClass.getEntityName(),
table.getName() );
( (TableOwner) persistentClass ).setTable( table );
}
else {
@@ -630,12 +628,9 @@
else if ( joinTable != null ) {
joinColumns = joinTable.joinColumns();
}
- if ( log.isInfoEnabled() ) {
- log.info(
- "Adding secondary table to entity " + persistentClass.getEntityName() +
" -> " + join.getTable()
- .getName()
- );
- }
+ log.info(
+ "Adding secondary table to entity {} -> {}",
persistentClass.getEntityName(), join.getTable().getName()
+ );
org.hibernate.annotations.Table matchingTable = findMatchingComplimentTableAnnotation(
join );
if ( matchingTable != null ) {
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/ListBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/ListBinder.java 2008-05-17
12:47:32 UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/ListBinder.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -2,8 +2,6 @@
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.OrderBy;
@@ -24,6 +22,8 @@
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Bind a list
@@ -32,7 +32,7 @@
* @author Emmanuel Bernard
*/
public class ListBinder extends CollectionBinder {
- private static Log log = LogFactory.getLog( ListBinder.class );
+ private Logger log = LoggerFactory.getLogger( ListBinder.class );
public ListBinder() {
}
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/PropertyBinder.java
===================================================================
---
annotations/trunk/src/java/org/hibernate/cfg/annotations/PropertyBinder.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/java/org/hibernate/cfg/annotations/PropertyBinder.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -4,8 +4,6 @@
import javax.persistence.EmbeddedId;
import javax.persistence.Id;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;
@@ -21,12 +19,14 @@
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Emmanuel Bernard
*/
public class PropertyBinder {
- private static Log log = LogFactory.getLog( PropertyBinder.class );
+ private Logger log = LoggerFactory.getLogger( PropertyBinder.class );
private String name;
private String returnedClassName;
private boolean lazy;
@@ -103,9 +103,7 @@
public Property bind() {
validateBind();
- if ( log.isDebugEnabled() ) {
- log.debug( "binding property " + name + " with lazy=" + lazy );
- }
+ log.debug( "binding property {} with lazy={}", name, lazy );
String containerClassName = holder == null ?
null :
holder.getClassName();
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/QueryBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/QueryBinder.java 2008-05-17
12:47:32 UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/QueryBinder.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -10,8 +10,6 @@
import javax.persistence.SqlResultSetMapping;
import javax.persistence.SqlResultSetMappings;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.CacheMode;
@@ -26,6 +24,8 @@
import org.hibernate.engine.NamedSQLQueryDefinition;
import org.hibernate.engine.query.sql.NativeSQLQueryReturn;
import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Query binder
@@ -33,7 +33,7 @@
* @author Emmanuel Bernard
*/
public abstract class QueryBinder {
- private static Log log = LogFactory.getLog( QueryBinder.class );
+ private static final Logger log = LoggerFactory.getLogger( QueryBinder.class );
public static void bindQuery(NamedQuery queryAnn, ExtendedMappings mappings, boolean
isDefault) {
if ( queryAnn == null ) return;
@@ -61,7 +61,7 @@
else {
mappings.addQuery( queryAnn.name(), query );
}
- if ( log.isInfoEnabled() ) log.info( "Binding Named query: " +
queryAnn.name() + " => " + queryAnn.query() );
+ log.info( "Binding Named query: {} => {}", queryAnn.name(),
queryAnn.query() );
}
@@ -123,9 +123,7 @@
else {
mappings.addSQLQuery( queryAnn.name(), query );
}
- if ( log.isInfoEnabled() ) {
- log.info( "Binding named native query: " + queryAnn.name() + " =>
" + queryAnn.query() );
- }
+ log.info( "Binding named native query: {} => {}", queryAnn.name(),
queryAnn.query() );
}
public static void bindNativeQuery(org.hibernate.annotations.NamedNativeQuery queryAnn,
ExtendedMappings mappings) {
@@ -179,9 +177,7 @@
throw new NotYetImplementedException( "Pure native scalar queries are not yet
supported" );
}
mappings.addSQLQuery( queryAnn.name(), query );
- if ( log.isInfoEnabled() ) {
- log.info( "Binding named native query: " + queryAnn.name() + " =>
" + queryAnn.query() );
- }
+ log.info( "Binding named native query: {} => {}", queryAnn.name(),
queryAnn.query() );
}
public static void bindQueries(NamedQueries queriesAnn, ExtendedMappings mappings,
boolean isDefault) {
Modified:
annotations/trunk/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java
===================================================================
---
annotations/trunk/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/java/org/hibernate/cfg/annotations/ResultsetMappingSecondPass.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -13,8 +13,6 @@
import javax.persistence.FieldResult;
import javax.persistence.SqlResultSetMapping;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
import org.hibernate.cfg.BinderHelper;
@@ -30,12 +28,14 @@
import org.hibernate.mapping.Value;
import org.hibernate.util.CollectionHelper;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Emmanuel Bernard
*/
public class ResultsetMappingSecondPass implements QuerySecondPass {
- private static Log log = LogFactory.getLog( ResultsetMappingSecondPass.class );
+ private Logger log = LoggerFactory.getLogger( ResultsetMappingSecondPass.class );
private SqlResultSetMapping ann;
private ExtendedMappings mappings;
private boolean isDefault;
@@ -50,7 +50,7 @@
//TODO add parameters checkings
if ( ann == null ) return;
ResultSetMappingDefinition definition = new ResultSetMappingDefinition( ann.name() );
- if ( log.isInfoEnabled() ) log.info( "Binding resultset mapping: " +
definition.getName() );
+ log.info( "Binding resultset mapping: {}", definition.getName() );
int entityAliasIndex = 0;
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/SetBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/SetBinder.java 2008-05-17
12:47:32 UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/SetBinder.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -1,11 +1,11 @@
package org.hibernate.cfg.annotations;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.annotations.OrderBy;
import org.hibernate.cfg.Environment;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Bind a set.
@@ -13,7 +13,7 @@
* @author Matthew Inger
*/
public class SetBinder extends CollectionBinder {
- private static Log log = LogFactory.getLog( SetBinder.class );
+ private final Logger log = LoggerFactory.getLogger( SetBinder.class );
public SetBinder() {
}
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java
===================================================================
---
annotations/trunk/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/java/org/hibernate/cfg/annotations/SimpleValueBinder.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -10,8 +10,6 @@
import javax.persistence.Lob;
import javax.persistence.Temporal;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.Parameter;
@@ -32,12 +30,14 @@
import org.hibernate.type.SerializableToBlobType;
import org.hibernate.type.StringClobType;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Emmanuel Bernard
*/
public class SimpleValueBinder {
- private static Log log = LogFactory.getLog( SimpleValueBinder.class );
+ private Logger log = LoggerFactory.getLogger( SimpleValueBinder.class );
private String propertyName;
private String returnedClassName;
private Ejb3Column[] columns;
@@ -217,7 +217,7 @@
public SimpleValue make() {
validate();
- log.debug( "building SimpleValue for " + propertyName );
+ log.debug( "building SimpleValue for {}", propertyName );
if ( table == null ) {
table = columns[0].getTable();
}
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/TableBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/TableBinder.java 2008-05-17
12:47:32 UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/TableBinder.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -6,8 +6,6 @@
import java.util.List;
import javax.persistence.UniqueConstraint;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.Index;
@@ -26,6 +24,8 @@
import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Table related operations
@@ -34,7 +34,7 @@
*/
public class TableBinder {
//TODO move it to a getter/setter strategy
- private static Log log = LogFactory.getLog( TableBinder.class );
+ private static Logger log = LoggerFactory.getLogger( TableBinder.class );
private String schema;
private String catalog;
private String name;
@@ -181,11 +181,7 @@
* Get the columns of the mapped-by property
* copy them and link the copy to the actual value
*/
- if ( log.isDebugEnabled() ) {
- log.debug(
- "Retrieving property " + associatedClass.getEntityName() + "."
+ mappedByProperty
- );
- }
+ log.debug("Retrieving property {}.{}", associatedClass.getEntityName(),
mappedByProperty);
final Property property = associatedClass.getRecursiveProperty(
columns[0].getMappedBy() );
Iterator mappedByColumns;
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/Version.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/Version.java 2008-05-17
12:47:32 UTC (rev 14670)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/Version.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -1,18 +1,18 @@
//$Id: $
package org.hibernate.cfg.annotations;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Emmanuel Bernard
*/
public class Version {
public static final String VERSION = "3.3.1.GA";
- private static Log log = LogFactory.getLog( Version.class );
+ private static Logger log = LoggerFactory.getLogger( Version.class );
static {
- log.info( "Hibernate Annotations " + VERSION );
+ log.info( "Hibernate Annotations {}", VERSION );
}
public static void touch() {
Modified:
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java
===================================================================
---
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/EJB3OverridenAnnotationReader.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -80,8 +80,6 @@
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.dom4j.Attribute;
import org.dom4j.Element;
import org.hibernate.AnnotationException;
@@ -95,6 +93,8 @@
import org.hibernate.annotations.common.reflection.ReflectionUtil;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Encapsulates the overriding of Java annotations from an EJB 3.0 descriptor.
@@ -104,7 +104,7 @@
* @author Emmanuel Bernard
*/
public class EJB3OverridenAnnotationReader implements AnnotationReader {
- private static Log log = LogFactory.getLog( EJB3OverridenAnnotationReader.class );
+ private Logger log = LoggerFactory.getLogger( EJB3OverridenAnnotationReader.class );
private static final Map<Class, String> annotationToXml;
private static final String SCHEMA_VALIDATION = "Activate schema validation for
more informations";
private static final Filter FILTER = new Filter() {
@@ -391,8 +391,9 @@
for (Element subelement : (List<Element>) element.elements()) {
String propertyName = subelement.attributeValue( "name" );
if ( !properties.contains( propertyName ) ) {
- log.warn( "Property " + StringHelper.qualify( className, propertyName ) +
" not found in class"
- + " but described in <mapping-file/> (possible typo error)" );
+ log.warn( "Property {} not found in class"
+ + " but described in <mapping-file/> (possible typo error)",
+ StringHelper.qualify( className, propertyName ) );
}
}
}
Modified:
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/XMLContext.java
===================================================================
---
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/XMLContext.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/java/org/hibernate/cfg/annotations/reflection/XMLContext.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -6,17 +6,17 @@
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.dom4j.Document;
import org.dom4j.Element;
import org.hibernate.util.StringHelper;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
/**
* @author Emmanuel Bernard
*/
public class XMLContext {
- private static Log log = LogFactory.getLog( XMLContext.class );
+ private Logger log = LoggerFactory.getLogger( XMLContext.class );
private Default globalDefaults;
private Map<String, Element> classOverriding = new HashMap<String,
Element>();
private Map<String, Default> defaultsOverriding = new HashMap<String,
Default>();
@@ -102,7 +102,7 @@
if ( access != null ) localDefault.setAccess( access );
defaultsOverriding.put( className, localDefault );
- log.debug( "Adding XML overriding information for " + className );
+ log.debug( "Adding XML overriding information for {}", className );
addEntityListenerClasses( element, packageName, addedClasses );
}
}
@@ -118,8 +118,8 @@
//maybe switch it to warn?
if ( "entity-listener".equals( classOverriding.get( listenerClassName
).getName() ) ) {
log.info(
- "entity-listener duplication, first event definition will be used: "
- + listenerClassName
+ "entity-listener duplication, first event definition will be used:
{}",
+ listenerClassName
);
continue;
}
@@ -131,7 +131,7 @@
classOverriding.put( listenerClassName, listener );
}
}
- log.debug( "Adding XML overriding information for listener: " + listeners );
+ log.debug( "Adding XML overriding information for listener: {}", listeners
);
addedClasses.addAll( localAddedClasses );
return localAddedClasses;
}
Modified: annotations/trunk/src/java/org/hibernate/cfg/search/SearchConfiguration.java
===================================================================
---
annotations/trunk/src/java/org/hibernate/cfg/search/SearchConfiguration.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/java/org/hibernate/cfg/search/SearchConfiguration.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -10,8 +10,8 @@
import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.event.PostDeleteEventListener;
import org.hibernate.event.EventListeners;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
/**
* Helper methods initializing Hibernate Search event listeners
@@ -19,7 +19,7 @@
* @author Emmanuel Bernard
*/
public class SearchConfiguration {
- private static Log log = LogFactory.getLog( SearchConfiguration.class );
+ private static final Logger log = LoggerFactory.getLogger( SearchConfiguration.class );
public static void enableHibernateSearch(EventListeners eventListeners, Properties
properties) {
//add search events if the jar is available
Modified: annotations/trunk/src/java/org/hibernate/type/EnumType.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/type/EnumType.java 2008-05-17 12:47:32 UTC
(rev 14670)
+++ annotations/trunk/src/java/org/hibernate/type/EnumType.java 2008-05-17 12:49:38 UTC
(rev 14671)
@@ -13,14 +13,14 @@
import java.util.Map;
import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
+import org.hibernate.annotations.common.util.StringHelper;
import org.hibernate.usertype.EnhancedUserType;
import org.hibernate.usertype.ParameterizedType;
import org.hibernate.util.ReflectHelper;
-import org.hibernate.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Enum type mapper
@@ -30,12 +30,22 @@
*/
//TODO implements readobject/writeobject to recalculate the enumclasses
public class EnumType implements EnhancedUserType, ParameterizedType, Serializable {
- private static Log log = LogFactory.getLog( EnumType.class );
- private static final boolean IS_TRACE_ENABLED;
+ /**
+ * This is the old scheme where logging of parameter bindings and value extractions
+ * was controlled by the trace level enablement on the 'org.hibernate.type'
package...
+ * <p/>
+ * Originally was cached such because of performance of looking up the logger each time
+ * in order to check the trace-enablement. Driving this via a central Log-specific
class
+ * would alleviate that performance hit, and yet still allow more "normal"
logging usage/config.
+ */
+ private static final boolean IS_VALUE_TRACING_ENABLED = LoggerFactory.getLogger(
StringHelper.qualifier( Type.class.getName() ) ).isTraceEnabled();
+ private transient Logger log;
- static {
- //cache this, because it was a significant performance cost
- IS_TRACE_ENABLED = LogFactory.getLog( StringHelper.qualifier( Type.class.getName() )
).isTraceEnabled();
+ private Logger log() {
+ if ( log == null ) {
+ log = LoggerFactory.getLogger( getClass() );
+ }
+ return log;
}
public static final String ENUM = "enumClass";
@@ -74,8 +84,8 @@
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws
HibernateException, SQLException {
Object object = rs.getObject( names[0] );
if ( rs.wasNull() ) {
- if ( IS_TRACE_ENABLED ) {
- log.debug( "Returning null as column " + names[0] );
+ if ( IS_VALUE_TRACING_ENABLED ) {
+ log().debug( "Returning null as column {}", names[0] );
}
return null;
}
@@ -86,15 +96,15 @@
if ( ordinal < 0 || ordinal >= values.length ) {
throw new IllegalArgumentException( "Unknown ordinal value for enum " +
enumClass + ": " + ordinal );
}
- if ( IS_TRACE_ENABLED ) {
- log.debug( "Returning '" + ordinal + "' as column " +
names[0] );
+ if ( IS_VALUE_TRACING_ENABLED ) {
+ log().debug( "Returning '{}' as column {}", ordinal, names[0] );
}
return values[ordinal];
}
else {
String name = (String) object;
- if ( IS_TRACE_ENABLED ) {
- log.debug( "Returning '" + name + "' as column " +
names[0] );
+ if ( IS_VALUE_TRACING_ENABLED ) {
+ log().debug( "Returning '{}' as column {}", name, names[0] );
}
try {
return Enum.valueOf( enumClass, name );
@@ -108,22 +118,22 @@
public void nullSafeSet(PreparedStatement st, Object value, int index) throws
HibernateException, SQLException {
//if (!guessed) guessType( st, index );
if ( value == null ) {
- if ( IS_TRACE_ENABLED ) log.debug( "Binding null to parameter: " + index );
+ if ( IS_VALUE_TRACING_ENABLED ) log().debug( "Binding null to parameter:
{}", index );
st.setNull( index, sqlType );
}
else {
boolean isOrdinal = isOrdinal( sqlType );
if ( isOrdinal ) {
int ordinal = ( (Enum) value ).ordinal();
- if ( IS_TRACE_ENABLED ) {
- log.debug( "Binding '" + ordinal + "' to parameter: " +
index );
+ if ( IS_VALUE_TRACING_ENABLED ) {
+ log().debug( "Binding '{}' to parameter: {}", ordinal, index );
}
st.setObject( index, Integer.valueOf( ordinal ), sqlType );
}
else {
String enumString = ( (Enum) value ).name();
- if ( IS_TRACE_ENABLED ) {
- log.debug( "Binding '" + enumString + "' to parameter: "
+ index );
+ if ( IS_VALUE_TRACING_ENABLED ) {
+ log().debug( "Binding '{}' to parameter: {}", enumString, index
);
}
st.setObject( index, enumString, sqlType );
}
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/reflection/LogListener.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/reflection/LogListener.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/reflection/LogListener.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -4,23 +4,24 @@
import javax.persistence.PrePersist;
import javax.persistence.PostPersist;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* @author Emmanuel Bernard
*/
public class LogListener {
- Log log = LogFactory.getLog( LogListener.class );
+ private final Logger log = LoggerFactory.getLogger( LogListener.class );
@PrePersist
@PostPersist
public void log(Object entity) {
- log.debug( "Logging entity " + entity.getClass().getName() + " with
hashCode: " + entity.hashCode() );
+ log.debug( "Logging entity {} with hashCode: {}",
entity.getClass().getName(), entity.hashCode() );
}
public void noLog(Object entity) {
- log.debug( "NoLogging entity " + entity.getClass().getName() + " with
hashCode: " + entity.hashCode() );
+ log.debug( "NoLogging entity {} with hashCode: {}",
entity.getClass().getName(), entity.hashCode() );
}
}
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/reflection/OtherLogListener.java
===================================================================
---
annotations/trunk/src/test/org/hibernate/test/annotations/reflection/OtherLogListener.java 2008-05-17
12:47:32 UTC (rev 14670)
+++
annotations/trunk/src/test/org/hibernate/test/annotations/reflection/OtherLogListener.java 2008-05-17
12:49:38 UTC (rev 14671)
@@ -4,23 +4,24 @@
import javax.persistence.PrePersist;
import javax.persistence.PostPersist;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* @author Emmanuel Bernard
*/
public class OtherLogListener {
- Log log = LogFactory.getLog( OtherLogListener.class );
+ private final Logger log = LoggerFactory.getLogger( OtherLogListener.class );
@PrePersist
@PostPersist
public void log(Object entity) {
- log.debug( "Logging entity " + entity.getClass().getName() + " with
hashCode: " + entity.hashCode() );
+ log.debug( "Logging entity {} with hashCode: {}",
entity.getClass().getName(), entity.hashCode() );
}
public void noLog(Object entity) {
- log.debug( "NoLogging entity " + entity.getClass().getName() + " with
hashCode: " + entity.hashCode() );
+ log.debug( "NoLogging entity {} with hashCode: {}",
entity.getClass().getName(), entity.hashCode() );
}
}