James Wong
2013-03-04 13:59:55 UTC
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]
"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]