[jboss-user] [Datasource Configuration] - My datasource don't create a transaction

James Wong do-not-reply at jboss.com
Mon Mar 4 08:59:55 EST 2013


James Wong [https://community.jboss.org/people/jwong22] created the discussion

"My datasource don't create a transaction"

To view the discussion, visit: https://community.jboss.org/message/800606#800606

--------------------------------------------------------------
Hello 
   I have some problem with my database connection.
   When i want to persist my object to my database, the server don't throw an exception but it don't insert into my table.
   And when i see my debug log, it says 

14:50:21,848 DEBUG [org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl] (http-localhost-127.0.0.1-8080-1) Skipping JTA sync registration due to auto join checking
14:50:21,850 DEBUG [org.hibernate.engine.jdbc.internal.LogicalConnectionImpl] (http-localhost-127.0.0.1-8080-1) Obtaining JDBC connection
14:50:21,851 DEBUG [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (http-localhost-127.0.0.1-8080-1) EiadDs: getConnection(null, null) [1/20]

standelone.xml  datasources
|              | <datasource jndi-name="java:jboss/datasources/EiadDS" pool-name="EiadDs" enabled="true" use-java-context="true" use-ccm="true"> |
|                  | <connection-url>jdbc:mysql://localhost:3306/eiad</connection-url> |
|                  | <driver>mysql</driver> |
|                  | <security> |
|                      | <user-name>user</user-name> |
|                      | <password>user</password> |
|                  | </security> |
|                  | <statement> |
|                      | <prepared-statement-cache-size>100</prepared-statement-cache-size> |
|                      | <share-prepared-statements>true</share-prepared-statements> |
|                  | </statement> |
|              | </datasource> |
|              | <drivers> |
|                  | <driver name="mysql" module="com.mysql"/>
</drivers> |

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence  http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="eiad-ejbPU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>java:jboss/datasources/EiadDS</jta-data-source>
    <class>fr.eiad.business.Temps</class>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.show_sql" value="true" />
      <property name="hibernate.format_sql" value="true" />
      <property name="hibernate.show_sql" value="true" />
      <property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/EntityManagerFactory" />
      <property name="hibernate.jdbc.factory_class" value="net.bull.javamelody.HibernateBatcherFactory" />
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
    </properties>
  </persistence-unit>
</persistence>


EntityService.java 


| private EntityManager | entityManager = EntityManagerHome.getEntityManager(); |

  public void persist(final Temps temps)
  {
| 
 | log.debug("persisting Temps instance"); //$NON-NLS-1$ |
| 
 | entityManager.persist(temps); |
  }
  public final Temps findById(final Integer id)
  {
| 
 | log.debug("getting User instance with id: " + id); |
| 
 | try |
| 
 | { |
|    | final EntityManagerHome entityhome = new EntityManagerHome(); |
|    | entityManager = EntityManagerHome.getEntityManager(); |
|    | final Temps instance = entityManager.find(Temps.class, id); |
|    | log.debug("get successful"); |
|    | return instance; |
| 
 | } |
| 
 | catch (final RuntimeException re) |
| 
 | { |
|    | log.error("get failed", re); |
|    | throw re; |
| 
 | } |
  }





  public static EntityManager getEntityManager()
  {
    EntityManagerFactory emf;
    try
    {
      emf = (EntityManagerFactory)InitialContext.doLookup("java:jboss/EntityManagerFactory"); //$NON-NLS-1$
      if (emf != null)
      {
        em = emf.createEntityManager();
 
      }
      if (em != null)
      {
        log.debug("Em Cree"); //$NON-NLS-1$
      }
      else
      {
        log.debug("Em plante"); //$NON-NLS-1$
      }
    }
    catch (final NamingException e)
    {
      throw new IllegalStateException("EntityManagerFactory cannot create entity manager"); //$NON-NLS-1$
    }
    return em;
  }
 
 
 
 


     It's an datasources error or and bad persistence.xml ?

Thanks
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/800606#800606]

Start a new discussion in Datasource Configuration at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2077]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130304/6a438bd5/attachment-0001.html 


More information about the jboss-user mailing list