title: Hibernate with Glassfish 4.1
body: <p>I've setted up Hibernate on Glassfish 4.1 but I'm having problems with persistence.
  I'm able to read data, but <strong>cannot write to BD</strong> (changes appear to not be commited).</p>
  
  <p>My current persistent.xml looks like this:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_1.xsd"&gt;
    &lt;persistence-unit name="myPU" transaction-type="JTA"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;jta-data-source&gt;jdbc/myDataSource&lt;/jta-data-source&gt;
      &lt;properties&gt;
        &lt;property name="transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/&gt;
        &lt;property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory"/&gt;
        &lt;property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/&gt;
        &lt;property name="hibernate.dialect" value="org.hibernate.dialect.SQLServer2008Dialect"/&gt;
      &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt;
  </code></pre>
  
  <p>My connection pool config on Glassfish is:</p>
  
  <pre><code>&lt;jdbc-connection-pool datasource-classname="com.microsoft.sqlserver.jdbc.SQLServerDataSource" steady-pool-size="2" name="myPool" res-type="javax.sql.DataSource"&gt;
    &lt;property name="TrustServerCertificate" value="false"&gt;&lt;/property&gt;
    &lt;property name="User" value="sa"&gt;&lt;/property&gt;
    &lt;property name="LastUpdateCount" value="true"&gt;&lt;/property&gt;
    &lt;property name="ResponseBuffering" value="adaptive"&gt;&lt;/property&gt;
    &lt;property name="URL" value="jdbc:sqlserver://server\bd"&gt;&lt;/property&gt;
    &lt;property name="XopenStates" value="false"&gt;&lt;/property&gt;
    &lt;property name="PacketSize" value="8000"&gt;&lt;/property&gt;
    &lt;property name="Password" value="mypass"&gt;&lt;/property&gt;
    &lt;property name="ApplicationName" value="Microsoft JDBC Driver for SQL Server"&gt;&lt;/property&gt;
    &lt;property name="DatabaseName" value="MyDB"&gt;&lt;/property&gt;
    &lt;property name="Encrypt" value="false"&gt;&lt;/property&gt;
    &lt;property name="LockTimeout" value="-1"&gt;&lt;/property&gt;
    &lt;property name="SendStringParametersAsUnicode" value="true"&gt;&lt;/property&gt;
    &lt;property name="MultiSubnetFailover" value="false"&gt;&lt;/property&gt;
    &lt;property name="ApplicationIntent" value="readwrite"&gt;&lt;/property&gt;
    &lt;property name="LoginTimeout" value="15"&gt;&lt;/property&gt;
    &lt;property name="WorkstationID" value="My-MacBook-Pro.local"&gt;&lt;/property&gt;
    &lt;property name="ServerName" value="xpto"&gt;&lt;/property&gt;
    &lt;property name="PortNumber" value="1433"&gt;&lt;/property&gt;
    &lt;property name="SelectMethod" value="direct"&gt;&lt;/property&gt;
    &lt;property name="SendTimeAsDatetime" value="true"&gt;&lt;/property&gt;
  &lt;/jdbc-connection-pool&gt;
  </code></pre>
  
  <p>Datasource config:</p>
  
  <pre><code>&lt;jdbc-resource pool-name="myPool" jndi-name="jdbc/myDataSource"&gt;&lt;/jdbc-resource&gt;
  </code></pre>
  
  <p>My EJB looks like this:</p>
  
  <pre><code>@PersistenceContext
  private EntityManager em;
  
  public void updateUser(User u) {
          em.merge(u);
  }
  </code></pre>
  
  <p>Any idea how I can fix that?</p>
  
  <p>Thanks!</p>