4 Replies Latest reply on May 28, 2009 10:01 AM by aditya bora

    Transient column error in where clause

    aditya bora Newbie
      Hi Friends,

      In my application i have one entity class of Department. I need to show all the department fields in the datatable. Now Department Description is stored in some different table. So to make it visible in the department data table i have created one transient variable for department description in Department entity class. I am successful in displaying department description at the front end; also quick filter is working fine.

      But the problem is that when i forcefully specify some condition on this transient column it raises an exception as shown below:

      Code in the Entity Class:

      private String deptDesc = null;

      @Transient
      public String getDeptDesc(){
        return this.deptDesc ;
      }
      public void setDeptDesc(String deptDesc){
        this.deptDesc = deptDesc;
      }

      Data Table Query:
      select dept from Dept dept where deptDesc = 'CSC'

      Error:
      Caused by: javax.el.ELException: /ec_dept_grid.xhtml @121,199 value="#{deptManagerList.resultList}": Error reading 'resultLis
      t' on type com.ec.sessionbean.material.dept.ECDeptListManager_$$_javassist_20
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
              at javax.faces.component.UIData.getValue(UIData.java:609)
              ... 62 more
      Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
              at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
              at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
              at org.jboss.seam.framework.EntityQuery.initResultList(EntityQuery.java:74)
              at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:65)
              at sun.reflect.GeneratedMethodAccessor374.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:95)
              at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
              at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:89)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
              at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
              at com.ec.sessionbean.material.dept.ECDeptListManager_$$_javassist_20.getResultList(ECDeptListManager_$$_javassist_20
      .java)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.
      11:52:24,619 ERROR [STDERR] reflect.Method.invoke(Method.java:597)
              at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
              at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
              at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
              at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
              at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
              at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
              ... 63 more
      Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
              at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
              at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
              at org.hibernate.loader.Loader.doList(Loader.java:2223)
              at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
              at org.hibernate.loader.Loader.list(Loader.java:2099)
              at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
              at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
              at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
              at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
              at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
              at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)
              ... 94 more
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'deptDesc' in 'where clause'
              at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
              at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
              at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
              at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
              at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
              at com.mysql.jdbc.Util.getInstance(Util.java:381)
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
              at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
              at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
              at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
              at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
              at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
              at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
              at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:342)
              at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
              at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
              at org.hibernate.loader.Loader.doQuery(Loader.java:674)
              at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
              at org.hibernate.loader.Loader.doList(Loader.java:2220)
              ... 102 more
        • 1. Re: Transient column error in where clause
          aditya bora Newbie

          Please help me somebody. This is urgent.


          Thankx in Advance
          Aditya(Eddie)

          • 2. Re: Transient column error in where clause
            Arbi Sookazian Master

            I modded the Hotel booking example as follows:


            Booking entity:


               
               @Transient
               public int getBeds()
               {
                  return beds;
               }



            HotelBookingAction:


               public void setBookingDetails()
               {
                  Calendar calendar = Calendar.getInstance();
                  calendar.add(Calendar.DAY_OF_MONTH, -1);
                  if ( booking.getCheckinDate().before( calendar.getTime() ) )
                  {
                     facesMessages.addToControl("checkinDate", "Check in date must be a future date");
                     bookingValid=false;
                  }
                  else if ( !booking.getCheckinDate().before( booking.getCheckoutDate() ) )
                  {
                     facesMessages.addToControl("checkoutDate", "Check out date must be later than check in date");
                     bookingValid=false;
                  }
                  else
                  {
                     bookingValid=true;
                  }
            
                  //testing
            
                  java.util.List<Booking> list = em.createQuery("select b from Booking b where b.beds = 1").getResultList();
                  //end testing
               }



            I executed the use case to completion (i.e. @End of conversation) and no exceptions in server.log like yours.  Sorry, not sure what's causing your error...

            • 3. Re: Transient column error in where clause
              Zoltan Tiringer Newbie

              Transient fields are not stored in the DB, so you cannot include them in the where clause of a query if you don't provide some way to resolve them to real DB columns. What you can do is link the Dept and Dept Desc tables with OneToOne or OneToMany annotation etc. and then modify query to something like


              select dept from Dept dept join fetch dept.deptDesc deptDesc where deptDesc = 'CSC'


              • 4. Re: Transient column error in where clause
                aditya bora Newbie

                Sorry, as i cud not respond to the replies, as i go busy with some other area.. Thanks for your replies.


                This is what i cannot do. I cannot join two tables, as i am caching the descriptions of all the departments. This is a special requirement. So I am trying to create a transient variables wich actually fetch descriptions of the department from the cache.