logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickwilli...@apache.org
Subject svn commit: r1500366 - in /logging/log4j/log4j2/trunk: ./ core/ core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/ core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ core/src/test/java/org/apache/logging/log4j/co...
Date Sun, 07 Jul 2013 03:51:03 GMT
Author: nickwilliams
Date: Sun Jul  7 03:51:02 2013
New Revision: 1500366

URL: http://svn.apache.org/r1500366
Log:
- Updated the JPA 2.1 artifact to the final version
- Switched from using incomplete JPA 2.1 implementation (Hibernate) to the complete, reference implementation (EclipseLink)
- Now that the JPAAppender is finally testable, fixed lots of NPEs and other problems

Added:
    logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/orm.xml
Modified:
    logging/log4j/log4j2/trunk/core/pom.xml
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractLogEventWrapperEntity.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/JPADatabaseManager.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverter.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverter.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverter.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverter.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverter.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverter.java
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverter.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverterTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverterTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverterTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverterTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverterTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverterTest.java
    logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverterTest.java
    logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml
    logging/log4j/log4j2/trunk/pom.xml
    logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml

Modified: logging/log4j/log4j2/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/pom.xml?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/pom.xml (original)
+++ logging/log4j/log4j2/trunk/core/pom.xml Sun Jul  7 03:51:02 2013
@@ -105,8 +105,8 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.hibernate</groupId>
-      <artifactId>hibernate-entitymanager</artifactId>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.jpa</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
@@ -135,8 +135,8 @@
       <optional>true</optional>
     </dependency>
     <dependency>
-      <groupId>org.hibernate.javax.persistence</groupId>
-      <artifactId>hibernate-jpa-2.1-api</artifactId>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>javax.persistence</artifactId>
       <scope>compile</scope>
       <optional>true</optional>
     </dependency>

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractLogEventWrapperEntity.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractLogEventWrapperEntity.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractLogEventWrapperEntity.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/AbstractLogEventWrapperEntity.java Sun Jul  7 03:51:02 2013
@@ -17,6 +17,8 @@
 package org.apache.logging.log4j.core.appender.db.jpa;
 
 import java.util.Map;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
 import javax.persistence.MappedSuperclass;
 import javax.persistence.Transient;
 
@@ -55,6 +57,7 @@ import org.apache.logging.log4j.message.
  * @see BasicLogEventEntity
  */
 @MappedSuperclass
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
 public abstract class AbstractLogEventWrapperEntity implements LogEvent {
     private static final long serialVersionUID = 1L;
 
@@ -67,7 +70,7 @@ public abstract class AbstractLogEventWr
      */
     @SuppressWarnings("unused")
     protected AbstractLogEventWrapperEntity() {
-        this(null);
+        this(new NullLogEvent());
     }
 
     /**
@@ -77,6 +80,9 @@ public abstract class AbstractLogEventWr
      * @param wrappedEvent The underlying event from which information is obtained.
      */
     protected AbstractLogEventWrapperEntity(final LogEvent wrappedEvent) {
+        if (wrappedEvent == null) {
+            throw new IllegalArgumentException("The wrapped event cannot be null.");
+        }
         this.wrappedEvent = wrappedEvent;
     }
 
@@ -234,4 +240,82 @@ public abstract class AbstractLogEventWr
     public final void setEndOfBatch(final boolean endOfBatch) {
         this.getWrappedEvent().setEndOfBatch(endOfBatch);
     }
+
+    private static class NullLogEvent implements LogEvent {
+
+        @Override
+        public Level getLevel() {
+            return null;
+        }
+
+        @Override
+        public String getLoggerName() {
+            return null;
+        }
+
+        @Override
+        public StackTraceElement getSource() {
+            return null;
+        }
+
+        @Override
+        public Message getMessage() {
+            return null;
+        }
+
+        @Override
+        public Marker getMarker() {
+            return null;
+        }
+
+        @Override
+        public String getThreadName() {
+            return null;
+        }
+
+        @Override
+        public long getMillis() {
+            return 0;
+        }
+
+        @Override
+        public Throwable getThrown() {
+            return null;
+        }
+
+        @Override
+        public Map<String, String> getContextMap() {
+            return null;
+        }
+
+        @Override
+        public ThreadContext.ContextStack getContextStack() {
+            return null;
+        }
+
+        @Override
+        public String getFQCN() {
+            return null;
+        }
+
+        @Override
+        public boolean isIncludeLocation() {
+            return false;
+        }
+
+        @Override
+        public void setIncludeLocation(boolean locationRequired) {
+
+        }
+
+        @Override
+        public boolean isEndOfBatch() {
+            return false;
+        }
+
+        @Override
+        public void setEndOfBatch(boolean endOfBatch) {
+
+        }
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/JPADatabaseManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/JPADatabaseManager.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/JPADatabaseManager.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/JPADatabaseManager.java Sun Jul  7 03:51:02 2013
@@ -36,9 +36,7 @@ public final class JPADatabaseManager ex
     private final Constructor<? extends AbstractLogEventWrapperEntity> entityConstructor;
     private final String persistenceUnitName;
 
-    private EntityManager entityManager;
     private EntityManagerFactory entityManagerFactory;
-    private EntityTransaction transaction;
 
     private JPADatabaseManager(final String name, final int bufferSize,
                                final Class<? extends AbstractLogEventWrapperEntity> entityClass,
@@ -53,18 +51,10 @@ public final class JPADatabaseManager ex
     @Override
     protected void connectInternal() {
         this.entityManagerFactory = Persistence.createEntityManagerFactory(this.persistenceUnitName);
-        this.entityManager = this.entityManagerFactory.createEntityManager();
-        this.transaction = this.entityManager.getTransaction();
     }
 
     @Override
     protected void disconnectInternal() {
-        this.transaction = null;
-
-        if (this.entityManager != null && this.entityManager.isOpen()) {
-            this.entityManager.close();
-        }
-
         if (this.entityManagerFactory != null && this.entityManagerFactory.isOpen()) {
             this.entityManagerFactory.close();
         }
@@ -72,8 +62,7 @@ public final class JPADatabaseManager ex
 
     @Override
     protected void writeInternal(final LogEvent event) {
-        if (!this.isConnected() || this.transaction == null || this.entityManager == null
-                || this.entityManagerFactory == null) {
+        if (!this.isConnected() || this.entityManagerFactory == null) {
             LOGGER.error("Cannot write logging event; manager [{}] not connected to the database.", this.getName());
             return;
         }
@@ -86,13 +75,22 @@ public final class JPADatabaseManager ex
             return;
         }
 
+        EntityManager entityManager = null;
+        EntityTransaction transaction = null;
         try {
-            this.transaction.begin();
-            this.entityManager.persist(entity);
-            this.transaction.commit();
+            entityManager = this.entityManagerFactory.createEntityManager();
+            transaction = entityManager.getTransaction();
+            transaction.begin();
+            entityManager.persist(entity);
+            transaction.commit();
         } catch (final Exception e) {
             LOGGER.error("Failed to persist log event entity.", e);
-            this.transaction.rollback();
+            if (transaction != null && transaction.isActive())
+                transaction.rollback();
+        } finally {
+            if (entityManager != null && entityManager.isOpen()) {
+                entityManager.close();
+            }
         }
     }
 

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverter.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverter.java Sun Jul  7 03:51:02 2013
@@ -31,6 +31,10 @@ import javax.persistence.Converter;
 public class ContextMapAttributeConverter implements AttributeConverter<Map<String, String>, String> {
     @Override
     public String convertToDatabaseColumn(final Map<String, String> contextMap) {
+        if (contextMap == null) {
+            return null;
+        }
+
         return contextMap.toString();
     }
 

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverter.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverter.java Sun Jul  7 03:51:02 2013
@@ -37,6 +37,10 @@ public class ContextMapJsonAttributeConv
 
     @Override
     public String convertToDatabaseColumn(final Map<String, String> contextMap) {
+        if (contextMap == null) {
+            return null;
+        }
+
         try {
             return OBJECT_MAPPER.writeValueAsString(contextMap);
         } catch (IOException e) {

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverter.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverter.java Sun Jul  7 03:51:02 2013
@@ -32,6 +32,10 @@ import org.apache.logging.log4j.ThreadCo
 public class ContextStackAttributeConverter implements AttributeConverter<ThreadContext.ContextStack, String> {
     @Override
     public String convertToDatabaseColumn(final ThreadContext.ContextStack contextStack) {
+        if (contextStack == null) {
+            return null;
+        }
+
         StringBuilder builder = new StringBuilder();
         for (String value : contextStack.asList()) {
             if (builder.length() > 0) {

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverter.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverter.java Sun Jul  7 03:51:02 2013
@@ -38,6 +38,10 @@ import com.fasterxml.jackson.core.type.T
 public class ContextStackJsonAttributeConverter implements AttributeConverter<ThreadContext.ContextStack, String> {
     @Override
     public String convertToDatabaseColumn(final ThreadContext.ContextStack contextStack) {
+        if (contextStack == null) {
+            return null;
+        }
+
         try {
             return ContextMapJsonAttributeConverter.OBJECT_MAPPER.writeValueAsString(contextStack.asList());
         } catch (IOException e) {

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverter.java Sun Jul  7 03:51:02 2013
@@ -30,6 +30,10 @@ import org.apache.logging.log4j.MarkerMa
 public class MarkerAttributeConverter implements AttributeConverter<Marker, String> {
     @Override
     public String convertToDatabaseColumn(final Marker marker) {
+        if (marker == null) {
+            return null;
+        }
+
         StringBuilder builder = new StringBuilder(marker.getName());
         Marker parent = marker.getParent();
         int levels = 0;
@@ -51,6 +55,10 @@ public class MarkerAttributeConverter im
 
     @Override
     public Marker convertToEntityAttribute(final String s) {
+        if (s == null || s.length() == 0) {
+            return null;
+        }
+
         int bracket = s.indexOf("[");
 
         return bracket < 1 ? MarkerManager.getMarker(s) : MarkerManager.getMarker(s.substring(0, bracket));

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverter.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverter.java Sun Jul  7 03:51:02 2013
@@ -32,11 +32,19 @@ public class MessageAttributeConverter i
 
     @Override
     public String convertToDatabaseColumn(final Message message) {
+        if (message == null) {
+            return null;
+        }
+
         return message.getFormattedMessage();
     }
 
     @Override
     public Message convertToEntityAttribute(final String s) {
+        if (s == null || s.length() == 0) {
+            return null;
+        }
+
         return log.getMessageFactory().newMessage(s);
     }
 }

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverter.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverter.java Sun Jul  7 03:51:02 2013
@@ -29,11 +29,19 @@ public class StackTraceElementAttributeC
 
     @Override
     public String convertToDatabaseColumn(final StackTraceElement element) {
+        if (element == null) {
+            return null;
+        }
+
         return element.toString();
     }
 
     @Override
     public StackTraceElement convertToEntityAttribute(final String s) {
+        if (s == null || s.length() == 0) {
+            return null;
+        }
+
         return StackTraceElementAttributeConverter.convertString(s);
     }
 

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverter.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverter.java Sun Jul  7 03:51:02 2013
@@ -50,6 +50,10 @@ public class ThrowableAttributeConverter
 
     @Override
     public String convertToDatabaseColumn(final Throwable throwable) {
+        if (throwable == null) {
+            return null;
+        }
+
         StringBuilder builder = new StringBuilder();
         this.convertThrowable(builder, throwable);
         return builder.toString();

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/JPAAppenderTest.java Sun Jul  7 03:51:02 2013
@@ -33,7 +33,6 @@ import org.apache.logging.log4j.core.Log
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.config.DefaultConfiguration;
 import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
@@ -53,8 +52,10 @@ public class JPAAppenderTest {
 
         statement = this.connection.createStatement();
         statement.executeUpdate("CREATE TABLE jpaBasicLogEntry ( " +
-                    "id INTEGER IDENTITY, millis BIGINT, level VARCHAR(10), logger VARCHAR(255), " +
-                    "message VARCHAR(1024), thrown VARCHAR(1048576), contextMapJson VARCHAR(1048576)" +
+                    "id INTEGER IDENTITY, millis BIGINT, level VARCHAR(10), loggerName VARCHAR(255), " +
+                    "message VARCHAR(1024), thrown VARCHAR(1048576), contextMapJson VARCHAR(1048576)," +
+                    "fqcn VARCHAR(1024), contextStack VARCHAR(1048576), marker VARCHAR(255), source VARCHAR(2048)," +
+                    "threadName VARCHAR(255)" +
                 " )");
         statement.close();
 
@@ -89,7 +90,8 @@ public class JPAAppenderTest {
                     if (statement != null) {
                         statement.close();
                     }
-                } catch (final SQLException ignore) { /* */
+                } catch (final SQLException ignore) {
+                    /* */
                 }
             }
 
@@ -145,7 +147,6 @@ public class JPAAppenderTest {
     }
 
     @Test
-    @Ignore("Until Hibernate fixes https://hibernate.atlassian.net/browse/HHH-8111")
     public void testBaseJpaEntityAppender() throws SQLException {
         try {
             this.setUp("log4j2-jpa-base.xml");
@@ -208,7 +209,6 @@ public class JPAAppenderTest {
     }
 
     @Test
-    @Ignore("Until Hibernate fixes https://hibernate.atlassian.net/browse/HHH-8111")
     public void testBasicJpaEntityAppender() throws SQLException {
         try {
             this.setUp("log4j2-jpa-basic.xml");
@@ -237,10 +237,10 @@ public class JPAAppenderTest {
             assertTrue("The date should be later than pre-logging (1).", date >= millis);
             assertTrue("The date should be earlier than now (1).", date <= System.currentTimeMillis());
             assertEquals("The level column is not correct (1).", "DEBUG", resultSet.getString("level"));
-            assertEquals("The logger column is not correct (1).", logger1.getName(), resultSet.getString("logger"));
+            assertEquals("The logger column is not correct (1).", logger1.getName(), resultSet.getString("loggerName"));
             assertEquals("The message column is not correct (1).", "Test my debug 01.",
                     resultSet.getString("message"));
-            assertNull("The exception column is not correct (1).", resultSet.getString("exception"));
+            assertNull("The exception column is not correct (1).", resultSet.getString("thrown"));
 
             assertTrue("There should be at least two rows.", resultSet.next());
 
@@ -248,10 +248,10 @@ public class JPAAppenderTest {
             assertTrue("The date should be later than pre-logging (2).", date >= millis);
             assertTrue("The date should be earlier than now (2).", date <= System.currentTimeMillis());
             assertEquals("The level column is not correct (2).", "WARN", resultSet.getString("level"));
-            assertEquals("The logger column is not correct (2).", logger1.getName(), resultSet.getString("logger"));
+            assertEquals("The logger column is not correct (2).", logger1.getName(), resultSet.getString("loggerName"));
             assertEquals("The message column is not correct (2).", "This is another warning 02.",
                     resultSet.getString("message"));
-            assertEquals("The exception column is not correct (2).", stackTrace, resultSet.getString("exception"));
+            assertEquals("The exception column is not correct (2).", stackTrace, resultSet.getString("thrown"));
 
             assertTrue("There should be three rows.", resultSet.next());
 
@@ -259,10 +259,10 @@ public class JPAAppenderTest {
             assertTrue("The date should be later than pre-logging (3).", date >= millis);
             assertTrue("The date should be earlier than now (3).", date <= System.currentTimeMillis());
             assertEquals("The level column is not correct (3).", "FATAL", resultSet.getString("level"));
-            assertEquals("The logger column is not correct (3).", logger2.getName(), resultSet.getString("logger"));
+            assertEquals("The logger column is not correct (3).", logger2.getName(), resultSet.getString("loggerName"));
             assertEquals("The message column is not correct (3).", "A fatal warning has been issued.",
                     resultSet.getString("message"));
-            assertNull("The exception column is not correct (3).", resultSet.getString("exception"));
+            assertNull("The exception column is not correct (3).", resultSet.getString("thrown"));
 
             assertFalse("There should not be four rows.", resultSet.next());
         } finally {

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBaseEntity.java Sun Jul  7 03:51:02 2013
@@ -81,68 +81,69 @@ public class TestBaseEntity extends Abst
     @Enumerated(EnumType.STRING)
     @Column(name = "level")
     public Level getLevel() {
-        return getWrappedEvent().getLevel();
+        return this.getWrappedEvent().getLevel();
     }
 
     @Override
     @Basic
     @Column(name = "logger")
     public String getLoggerName() {
-        return getWrappedEvent().getLoggerName();
+        return this.getWrappedEvent().getLoggerName();
     }
 
     @Override
     @Transient
     public StackTraceElement getSource() {
-        return getWrappedEvent().getSource();
+        return this.getWrappedEvent().getSource();
     }
 
     @Override
     @Convert(converter = MessageAttributeConverter.class)
+    @Column(name = "message")
     public Message getMessage() {
-        return getWrappedEvent().getMessage();
+        return this.getWrappedEvent().getMessage();
     }
 
     @Override
     @Transient
     public Marker getMarker() {
-        return getWrappedEvent().getMarker();
+        return this.getWrappedEvent().getMarker();
     }
 
     @Override
     @Transient
     public String getThreadName() {
-        return getWrappedEvent().getThreadName();
+        return this.getWrappedEvent().getThreadName();
     }
 
     @Override
     @Transient
     public long getMillis() {
-        return getWrappedEvent().getMillis();
+        return this.getWrappedEvent().getMillis();
     }
 
     @Override
     @Convert(converter = ThrowableAttributeConverter.class)
     @Column(name = "exception")
     public Throwable getThrown() {
-        return getWrappedEvent().getThrown();
+        return this.getWrappedEvent().getThrown();
     }
 
     @Override
     @Transient
     public Map<String, String> getContextMap() {
-        return getWrappedEvent().getContextMap();
+        return this.getWrappedEvent().getContextMap();
     }
 
     @Override
     @Transient
     public ThreadContext.ContextStack getContextStack() {
-        return getWrappedEvent().getContextStack();
+        return this.getWrappedEvent().getContextStack();
     }
 
     @Override
     @Transient
     public String getFQCN() {
-        return getWrappedEvent().getFQCN();
+        return this.getWrappedEvent().getFQCN();
     }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/TestBasicEntity.java Sun Jul  7 03:51:02 2013
@@ -24,10 +24,7 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
-import javax.persistence.Transient;
 
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.appender.db.jpa.converter.ContextMapJsonAttributeConverter;
 
@@ -59,39 +56,9 @@ public class TestBasicEntity extends Bas
     }
 
     @Override
-    @Transient
-    public StackTraceElement getSource() {
-        return super.getSource();
-    }
-
-    @Override
-    @Transient
-    public Marker getMarker() {
-        return super.getMarker();
-    }
-
-    @Override
-    @Transient
-    public String getThreadName() {
-        return super.getThreadName();
-    }
-
-    @Override
     @Convert(converter = ContextMapJsonAttributeConverter.class)
     @Column(name = "contextMapJson")
     public Map<String, String> getContextMap() {
         return super.getContextMap();
     }
-
-    @Override
-    @Transient
-    public ThreadContext.ContextStack getContextStack() {
-        return super.getContextStack();
-    }
-
-    @Override
-    @Transient
-    public String getFQCN() {
-        return super.getFQCN();
-    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverterTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapAttributeConverterTest.java Sun Jul  7 03:51:02 2013
@@ -24,6 +24,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
 public class ContextMapAttributeConverterTest {
     private ContextMapAttributeConverter converter;
@@ -59,6 +60,11 @@ public class ContextMapAttributeConverte
                 this.converter.convertToDatabaseColumn(map));
     }
 
+    @Test
+    public void testConvertNullToDatabaseColumn() {
+        assertNull("The converted value should be null.", this.converter.convertToDatabaseColumn(null));
+    }
+
     @Test(expected = UnsupportedOperationException.class)
     public void testConvertToEntityAttribute() {
         this.converter.convertToEntityAttribute(null);

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverterTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextMapJsonAttributeConverterTest.java Sun Jul  7 03:51:02 2013
@@ -70,4 +70,15 @@ public class ContextMapJsonAttributeConv
         assertNotNull("The reversed value should not be null.", reversed);
         assertEquals("The reversed value is not correct.", map, reversed);
     }
+
+    @Test
+    public void testConvertNullToDatabaseColumn() {
+        assertNull("The converted value should be null.", this.converter.convertToDatabaseColumn(null));
+    }
+
+    @Test
+    public void testConvertNullOrBlankToEntityAttribute() {
+        assertNull("The converted attribute should be null (1).", this.converter.convertToEntityAttribute(null));
+        assertNull("The converted attribute should be null (2).", this.converter.convertToEntityAttribute(""));
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverterTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackAttributeConverterTest.java Sun Jul  7 03:51:02 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.logging.log4j.core.appender.db.jpa.converter;
 
-import static org.junit.Assert.*;
-
 import java.util.Arrays;
 
 import org.apache.logging.log4j.ThreadContext;
@@ -26,6 +24,8 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class ContextStackAttributeConverterTest {
     private ContextStackAttributeConverter converter;
 
@@ -58,6 +58,11 @@ public class ContextStackAttributeConver
                 this.converter.convertToDatabaseColumn(stack));
     }
 
+    @Test
+    public void testConvertNullToDatabaseColumn() {
+        assertNull("The converted value should be null.", this.converter.convertToDatabaseColumn(null));
+    }
+
     @Test(expected = UnsupportedOperationException.class)
     public void testConvertToEntityAttribute() {
         this.converter.convertToEntityAttribute(null);

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ContextStackJsonAttributeConverterTest.java Sun Jul  7 03:51:02 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.logging.log4j.core.appender.db.jpa.converter;
 
-import static org.junit.Assert.*;
-
 import java.util.Arrays;
 
 import org.apache.logging.log4j.ThreadContext;
@@ -26,6 +24,8 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.*;
+
 public class ContextStackJsonAttributeConverterTest {
     private ContextStackJsonAttributeConverter converter;
 
@@ -74,4 +74,15 @@ public class ContextStackJsonAttributeCo
         assertEquals("The reversed value is not correct.", stack.asList(),
                 reversed.asList());
     }
+
+    @Test
+    public void testConvertNullToDatabaseColumn() {
+        assertNull("The converted value should be null.", this.converter.convertToDatabaseColumn(null));
+    }
+
+    @Test
+    public void testConvertNullOrBlankToEntityAttribute() {
+        assertNull("The converted attribute should be null (1).", this.converter.convertToEntityAttribute(null));
+        assertNull("The converted attribute should be null (2).", this.converter.convertToEntityAttribute(""));
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverterTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MarkerAttributeConverterTest.java Sun Jul  7 03:51:02 2013
@@ -75,4 +75,15 @@ public class MarkerAttributeConverterTes
         assertNotNull("The second parent should not be null.", marker.getParent().getParent());
         assertEquals("The second parent is not correct.", "finalConvert03", marker.getParent().getParent().getName());
     }
+
+    @Test
+    public void testConvertNullToDatabaseColumn() {
+        assertNull("The converted value should be null.", this.converter.convertToDatabaseColumn(null));
+    }
+
+    @Test
+    public void testConvertNullOrBlankToEntityAttribute() {
+        assertNull("The converted attribute should be null (1).", this.converter.convertToEntityAttribute(null));
+        assertNull("The converted attribute should be null (2).", this.converter.convertToEntityAttribute(""));
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverterTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/MessageAttributeConverterTest.java Sun Jul  7 03:51:02 2013
@@ -53,4 +53,15 @@ public class MessageAttributeConverterTe
         assertNotNull("The reversed value should not be null.", reversed);
         assertEquals("The reversed value is not correct.", "Message #3 said [Hello].", reversed.getFormattedMessage());
     }
+
+    @Test
+    public void testConvertNullToDatabaseColumn() {
+        assertNull("The converted value should be null.", this.converter.convertToDatabaseColumn(null));
+    }
+
+    @Test
+    public void testConvertNullOrBlankToEntityAttribute() {
+        assertNull("The converted attribute should be null (1).", this.converter.convertToEntityAttribute(null));
+        assertNull("The converted attribute should be null (2).", this.converter.convertToEntityAttribute(""));
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverterTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/StackTraceElementAttributeConverterTest.java Sun Jul  7 03:51:02 2013
@@ -121,4 +121,15 @@ public class StackTraceElementAttributeC
         assertEquals("The line number is not correct.", -2, reversed.getLineNumber());
         assertTrue("The native flag should be true.", reversed.isNativeMethod());
     }
+
+    @Test
+    public void testConvertNullToDatabaseColumn() {
+        assertNull("The converted value should be null.", this.converter.convertToDatabaseColumn(null));
+    }
+
+    @Test
+    public void testConvertNullOrBlankToEntityAttribute() {
+        assertNull("The converted attribute should be null (1).", this.converter.convertToEntityAttribute(null));
+        assertNull("The converted attribute should be null (2).", this.converter.convertToEntityAttribute(""));
+    }
 }

Modified: logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverterTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverterTest.java?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverterTest.java (original)
+++ logging/log4j/log4j2/trunk/core/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverterTest.java Sun Jul  7 03:51:02 2013
@@ -73,6 +73,17 @@ public class ThrowableAttributeConverter
         assertEquals("The reversed value is not correct.", stackTrace, getStackTrace(reversed));
     }
 
+    @Test
+    public void testConvertNullToDatabaseColumn() {
+        assertNull("The converted value should be null.", this.converter.convertToDatabaseColumn(null));
+    }
+
+    @Test
+    public void testConvertNullOrBlankToEntityAttribute() {
+        assertNull("The converted attribute should be null (1).", this.converter.convertToEntityAttribute(null));
+        assertNull("The converted attribute should be null (2).", this.converter.convertToEntityAttribute(""));
+    }
+
     private static String getStackTrace(Throwable throwable) {
         String returnValue = throwable.toString() + "\n";
 

Added: logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/orm.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/orm.xml?rev=1500366&view=auto
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/orm.xml (added)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/orm.xml Sun Jul  7 03:51:02 2013
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
+                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm
+                                     http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd"
+                 version="2.1">
+  <!-- This is a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=412454. This file can be deleted
+   when that issue is fixed. -->
+  <converter class="org.apache.logging.log4j.core.appender.db.jpa.converter.ContextMapAttributeConverter" />
+  <converter class="org.apache.logging.log4j.core.appender.db.jpa.converter.ContextMapJsonAttributeConverter" />
+  <converter class="org.apache.logging.log4j.core.appender.db.jpa.converter.ContextStackAttributeConverter" />
+  <converter class="org.apache.logging.log4j.core.appender.db.jpa.converter.ContextStackJsonAttributeConverter" />
+  <converter class="org.apache.logging.log4j.core.appender.db.jpa.converter.MarkerAttributeConverter" />
+  <converter class="org.apache.logging.log4j.core.appender.db.jpa.converter.MessageAttributeConverter" />
+  <converter class="org.apache.logging.log4j.core.appender.db.jpa.converter.StackTraceElementAttributeConverter" />
+  <converter class="org.apache.logging.log4j.core.appender.db.jpa.converter.ThrowableAttributeConverter" />
+</entity-mappings>

Modified: logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml (original)
+++ logging/log4j/log4j2/trunk/core/src/test/resources/META-INF/persistence.xml Sun Jul  7 03:51:02 2013
@@ -16,26 +16,26 @@
  limitations under the License.
 
 -->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
-                                 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
-             version="1.0">
+             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
+                                 http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
+             version="2.1">
 
   <persistence-unit name="jpaAppenderTestUnit">
-    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
     <class>org.apache.logging.log4j.core.appender.db.jpa.TestBaseEntity</class>
-    <!--<class>org.apache.logging.log4j.core.appender.db.jpa.TestBasicEntity</class>
-      Until Hibernate fixes https://hibernate.atlassian.net/browse/HHH-8111-->
+    <class>org.apache.logging.log4j.core.appender.db.jpa.TestBasicEntity</class>
     <exclude-unlisted-classes>false</exclude-unlisted-classes>
+    <shared-cache-mode>NONE</shared-cache-mode>
     <properties>
-      <property name="hibernate.connection.username" value="sa" />
-      <property name="hibernate.connection.password" value="" />
-      <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
-      <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:Log4j;ifexists=true" />
-      <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
-      <property name="hibernate.show_sql" value="true" />
-      <property name="hibernate.format_sql" value="true" />
+      <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+      <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:Log4j;ifexists=true"/>
+      <property name="javax.persistence.jdbc.user" value="sa"/>
+      <property name="javax.persistence.jdbc.password" value=""/>
+      <property name="eclipselink.logging.level" value="FINE"/>
+      <property name="eclipselink.logging.level.sql" value="FINE"/>
+      <property name="eclipselink.logging.parameters" value="true"/>
     </properties>
   </persistence-unit>
 

Modified: logging/log4j/log4j2/trunk/pom.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/pom.xml?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/pom.xml (original)
+++ logging/log4j/log4j2/trunk/pom.xml Sun Jul  7 03:51:02 2013
@@ -423,14 +423,14 @@
         <version>1.3.172</version>
       </dependency>
       <dependency>
-        <groupId>org.hibernate</groupId>
-        <artifactId>hibernate-entitymanager</artifactId>
-        <version>4.3.0.Beta3</version>
+        <groupId>org.eclipse.persistence</groupId>
+        <artifactId>org.eclipse.persistence.jpa</artifactId>
+        <version>2.5.0</version>
       </dependency>
       <dependency>
-        <groupId>org.hibernate.javax.persistence</groupId>
-        <artifactId>hibernate-jpa-2.1-api</artifactId>
-        <version>1.0.0.Draft-16</version>
+        <groupId>org.eclipse.persistence</groupId>
+        <artifactId>javax.persistence</artifactId>
+        <version>2.1.0</version>
       </dependency>
       <dependency>
         <groupId>org.mongodb</groupId>

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml?rev=1500366&r1=1500365&r2=1500366&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/appenders.xml Sun Jul  7 03:51:02 2013
@@ -1217,7 +1217,7 @@
 <configuration status="error">
   <appenders>
     <Jdbc name="databaseAppender" tableName="dbo.application_log">
-      <DataSource jndiName="java:/comp/env/jdbc/ApplicationDataSource" />
+      <DataSource jndiName="java:/comp/env/jdbc/LoggingDataSource" />
       <Column name="eventDate" isEventTimestamp="true" />
       <Column name="level" pattern="%level" />
       <Column name="logger" pattern="%logger" />
@@ -1472,9 +1472,13 @@
         </subsection>
         <a name="JPAAppender"/>
         <subsection name="JPAAppender">
-          <p>The JPAAppender writes log events to a relational database table using the Java Persistence API.
+          <p>The JPAAppender writes log events to a relational database table using the Java Persistence API 2.1.
             It requires the API and a provider implementation be on the classpath. It also requires a decorated entity
-            configured to persist to the table desired.</p>
+            configured to persist to the table desired. The entity should either extend
+            org.apache.logging.log4j.core.appender.db.jpa.BasicLogEventEntity (if you mostly want to use the default
+            mappings) or org.apache.logging.log4j.core.appender.db.jpa.AbstractLogEventWrapperEntity (if you want to
+            significantly customize the mappings). See the Javadoc for these two classes for more information. You can
+            also consult the source code of these two classes as an example of how to implement the entity.</p>
           <table>
             <tr>
               <th>Parameter Name</th>
@@ -1519,13 +1523,17 @@
             <caption align="top">JPAAppender Parameters</caption>
           </table>
           <p>
-            Here is a sample configurations for the JPAAppender. The first XML sample is the Log4j configuration file,
-            the second is the persistence.xml file. Hibernate ORM is assumed here, but any JPA provider will do:
+            Here is a sample configuration for the JPAAppender. The first XML sample is the Log4j configuration file,
+            the second is the persistence.xml file. EclipseLink is assumed here, but any JPA provider will do. You
+            should <em>always</em> create a <em>separate</em> persistence unit for logging, for two reasons. First,
+            &lt;shared-cache-mode&gt; <em>must</em> be set to "NONE," which is usually not desired in normal JPA usage.
+            Also, for performance reasons the logging entity should be isolated in its own persistence unit away from
+            all other entities.
 
             <pre class="prettyprint linenums lang-xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
 <configuration status="error">
   <appenders>
-    <Jpa name="databaseAppender" persistenceUnitName="appPersistenceUnit"
+    <Jpa name="databaseAppender" persistenceUnitName="loggingPersistenceUnit"
          entityClassName="com.example.logging.JpaLogEntity" />
   </appenders>
   <loggers>
@@ -1536,26 +1544,26 @@
 </configuration>]]></pre>
 
             <pre class="prettyprint linenums lang-xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
-                                 http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
-             version="1.0">
-  <persistence-unit name="appPersistenceUnit">
-    <provider>org.hibernate.ejb.HibernatePersistence</provider>
-    <jpa-data-source>jdbc/ApplicationDataSource</jpa-data-source>
+             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
+                                 http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
+             version="2.1">
+
+  <persistence-unit name="loggingPersistenceUnit">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <non-jta-data-source>jdbc/LoggingDataSource</non-jta-data-source>
     <class>com.example.logging.JpaLogEntity</class>
-    <properties>
-      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
-    </properties>
+    <shared-cache-mode>NONE</shared-cache-mode>
   </persistence-unit>
+
 </persistence>]]></pre>
 
             <pre class="prettyprint linenums lang-java"><![CDATA[package com.example.logging;
 ...
 @Entity
 @Table(name="application_log", schema="dbo")
-public class JpaLogEntity extends LogEventWrapperEntity {
+public class JpaLogEntity extends AbstractLogEventWrapperEntity {
     private static final long serialVersionUID = 1L;
     private long id = 0L;
 



Mime
View raw message