title: JPA Hibernate "ERROR: ORA-00923: FROM keyword not found where expected" on merge
body: <p>I have an AbstractDAO class:</p>
  
  <pre><code>public abstract class AbstractDAO&lt;T&gt; {
  
      private Class&lt;T&gt; entityClass;
  
      protected abstract EntityManager getEntityManager();
  
      ...
      public T update(T entity) {
  
          return getEntityManager().merge(entity);
      }
      ...
  }
  </code></pre>
  
  <p>this class has the methods to persist, update, find, findAll, etc. I have DAO's that extends from this one, this SolicitudDAO is one of them:</p>
  
  <pre><code>@Stateless
  @LocalBean
  public class SolicitudDAO extends AbstractDAO&lt;Solicitud&gt;{
  
      @PersistenceContext
      EntityManager em;
  
      public SolicitudDAO() {
         super(Solicitud.class);
      }
  
      @Override
      protected EntityManager getEntityManager() {
          return this.em;
      }
  }
  </code></pre>
  
  <p>And and entity like:</p>
  
  <pre><code>@Entity
  @Table(name = "SOLICITUD")
     public class Solicitud implements Serializable {
  
      private Long folioSisap;
      private static final long serialVersionUID = 1L;
      @SequenceGenerator(name = "SOLICITUD_ID_SEQ", sequenceName = "SOLICITUD_ID_SEQ", allocationSize = 1, initialValue = 1)
      @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SOLICITUD_ID_SEQ")
      @Column(name = "SOLICITUD_ID")
      private Long solicitudId;
  
  }
  </code></pre>
  
  <p>From my view, I load my list through a findAll, then I can choose one element, and this is passed to a new Solicitud selectedSolicitud in my back bean. The problem is when I try to merge some changes this:</p>
  
  <pre><code>@EJB
  SolicitudDAO solicitudDAO;
  
  ...
  
  public Solicitud actualizaSolicitud(Solicitud solicitud) {
          solicitud.setFolioSisap(solicitud.getFolioSisap()+1);
          return solicitudDAO.update(solicitud);
  }
  
  ...
  </code></pre>
  
  <p>If I run this, in my log shows this stacktrace:</p>
  
  <p>...</p>
  
  <pre><code>WARN: SQL Error: 923, SQLState: 42000
  ERROR: ORA-00923: FROM keyword not found where expected
  
  INFO: HHH000327: Error performing load command : org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  WARNING: EJB5184:A system exception occurred during an invocation on EJB SolicitudDAO, method: public com.mx.gsce.model.entity.Solicitud com.mx.gsce.base.DAO.SolicitudDAO.update(com.mx.gsce.model.entity.Solicitud)
  WARNING: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
      at com.sun.ejb.containers.BaseContainer.checkExceptionClientTx(BaseContainer.java:5071)
      at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4906)
      at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045)
      at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
      at com.sun.proxy.$Proxy317.update(Unknown Source)
      at com.mx.gsce.base.DAO.__EJB31_Generated__SolicitudDAO__Intf____Bean__.update(Unknown Source)
      at com.mx.gsce.bo.impl.SolicitudBO.actualizaSolicitud(SolicitudBO.java:198)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
      at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
      at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
      at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
      at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
      at sun.reflect.GeneratedMethodAccessor217.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
      at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
      at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
      at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
      at com.sun.proxy.$Proxy333.actualizaSolicitud(Unknown Source)
      at com.mx.gsce.controller.AdministraSolicitudCertifController.autorizaSolicitud(AdministraSolicitudCertifController.java:62)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:779)
      at javax.el.BeanELResolver.invoke(BeanELResolver.java:528)
      at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:257)
      at com.sun.el.parser.AstValue.invoke(AstValue.java:248)
      at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:302)
      at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39)
      at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
      at javax.faces.component.UICommand.broadcast(UICommand.java:315)
      at javax.faces.component.UIData.broadcast(UIData.java:1093)
      at javax.faces.component.UIData.broadcast(UIData.java:1093)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
      at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
      at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
      at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
      at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
      at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
      at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
      at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
      at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
      at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
      at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
      at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
      at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
      at java.lang.Thread.run(Thread.java:724)
  Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
      at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
      at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
      at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1316)
      at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:898)
      at com.sun.enterprise.container.common.impl.EntityManagerWrapper.merge(EntityManagerWrapper.java:286)
      at com.mx.gsce.base.DAO.SolicitudDAO.update(SolicitudDAO.java:48)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
      at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
      at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
      at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
      at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
      at sun.reflect.GeneratedMethodAccessor217.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
      at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
      at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
      at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
      ... 75 more
  Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
      at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:61)
      at org.hibernate.loader.Loader.getResultSet(Loader.java:2040)
      at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1837)
      at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1816)
      at org.hibernate.loader.Loader.doQuery(Loader.java:900)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:312)
      at org.hibernate.loader.Loader.loadEntity(Loader.java:2121)
      at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
      at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
      at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3927)
      at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:460)
      at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:429)
      at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:206)
      at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262)
      at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:150)
      at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1092)
      at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:175)
      at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2476)
      at org.hibernate.internal.SessionImpl.get(SessionImpl.java:992)
      at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:271)
      at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:151)
      at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:76)
      at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:914)
      at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:898)
      at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:902)
      at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:889)
      ... 98 more
  Caused by: java.sql.SQLException: ORA-00923: FROM keyword not found where expected
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
      at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
      at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:810)
      at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
      at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:850)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1134)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3339)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3384)
      at com.sun.gjc.spi.jdbc40.PreparedStatementWrapper40.executeQuery(PreparedStatementWrapper40.java:642)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:56)
      ... 124 more
  </code></pre>
  
  <p></p>
  
  <p>This is my persistence.xml:</p>
  
  <pre><code>&lt;persistence-unit name="C-ejbPU" transaction-type="JTA"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;jta-data-source&gt;jdbc/appl&lt;/jta-data-source&gt;
      &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
      &lt;properties&gt;
        &lt;property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/&gt;
        &lt;property name="hibernate.max_fetch_depth" value="3"/&gt;
        &lt;property name="hibernate.jdbc.fetch_size" value="50"/&gt;
        &lt;property name="hibernate.show_sql" value="true"/&gt;
        &lt;property name="hibernate.current_session_context_class" value="thread"/&gt;
        &lt;!--property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/--&gt;
        &lt;property name="hibernate.connection.username" value="***"/&gt;
        &lt;property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/&gt;
        &lt;property name="hibernate.connection.password" value="***"/&gt;
        &lt;property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:XE"/&gt;
      &lt;/properties&gt;
    &lt;/persistence-unit&gt;
  </code></pre>
  
  <p>I'm Using JPA 2 implements Hibernate. BD Oracle 11g.</p>
  
  <p>"FROM keyword not found where expected"? C'mon, I'm not using JPQL, is just the "merge" JPA implementation.</p>
  
  <p>Thanks for your time.</p>