4 Replies Latest reply on Jan 13, 2009 2:44 PM by mstraub

    4.2.2 Switching name cases from proper case to camel case

      I have a case sensitive DB That has a field ServerAddress. The pojo has private int ServerAddress;
      public int getServerAddress()...
      public void setServerAdd5ress(int Val)...
      I am getting SQLGrammer exceptions stating it cant find field "serverAddress". NOTE Camel case on name. The only way I seem to be able to fix this is putting @Column tags on all my pojo fields. The camel casing is also happening on table names and entity names in WSDL. How do I turn this automated camel casing off? This did not happen with the 4.0.5 version.

        • 1. Re: 4.2.2 Switching name cases from proper case to camel cas
          jaikiran

          Please post the entire exception stacktrace. As for the case-sensitivity, i think its more on the DB server side than your java code. Make sure that you have correct settings on the DB server to allow case insensitive column names.

          • 2. Re: 4.2.2 Switching name cases from proper case to camel cas

            The database is case sensitive base on other requirements. (Not my decision.) However, JBoss is changing the case on many names when the beans are deployed. We did not have this problem until we upgraded from 4.0.5 to 4.2.2. Something in 4.2.2 is forcing names to camel case. We are having to put @Table and @Column tags in all entities. After tagging all of the methods the error goes away. It also camel cased some names in the WSDL that are proper case in the bean.
            Stack trace:

            2009-01-10 14:31:43,637 ERROR [org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS] SOAP request exception
            javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
             at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
             at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
             at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.remoting.ReplicantsManagerInterceptor.invoke(ReplicantsManagerInterceptor.java:51)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
             at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.wsf.container.jboss42.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:103)
             at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
             at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
             at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
             at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
             at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
             at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
             at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
             at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
             at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
             at java.lang.Thread.run(Thread.java:595)
            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 globaltec.serveremailserverinterface.serveremailserverinterface.GetServerAddresses(serveremailserverinterface.java:59)
             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.reflect.Method.invoke(Method.java:585)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
             at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
             at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
             at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
             ... 41 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)
             ... 55 more
            Caused by: java.sql.SQLException: Invalid column name 'serverAddress_ServerAddress'.
             at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
             at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2816)
             at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2254)
             at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:631)
             at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477)
             at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:777)
             at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:236)
             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)
             ... 63 more
            
            

            Bean Code
            @WebMethod ( operationName = "GetServerAddresses" )
             @WebResult ( name = "GetServerAddresses", targetNamespace = GTNameSpace.g_NameSpace )
             public globaltec.serveremailserverinterface.ServerAddress[] GetServerAddresses()
             {
             Query query = manager.createQuery( "SELECT c from ServerAddress AS c" );
             List<globaltec.serveremailserverinterface.ServerAddress> Items = (List<globaltec.serveremailserverinterface.ServerAddress>)query.getResultList();
             ServerAddress[] ObjArray = new ServerAddress[ Items.size()];
             int Index = 0;
             for (Iterator it = Items.iterator(); it.hasNext(); )
             {
             ObjArray[Index] = (ServerAddress)it.next();
             ++Index;
             }
             return ObjArray;
             }
            

            Entity Class:
            @XmlType(name="ServerAddress")
            @Table(name="dbo.ServerAddress")
            @Entity
            public class ServerAddress implements java.io.Serializable
            {
             private int ServerAddress;
             private String ServerAddress_ServerAddress;
             private int ServerAddress_Port;
             private String ServerAddress_Description;
            
             @Id
             @Column( name = "`ServerAddress`" )
             public int getServerAddress() {return ServerAddress;}
             public void setServerAddress( int Val ) {ServerAddress = Val;}
            
             public String getServerAddress_ServerAddress() {return ServerAddress_ServerAddress;}
             public void setServerAddress_ServerAddress( String Val ) {ServerAddress_ServerAddress = Val;}
            
             public int getServerAddress_Port() {return ServerAddress_Port;}
             public void setServerAddress_Port( int Val ) {ServerAddress_Port = Val;}
            
             public String getServerAddress_Description() {return ServerAddress_Description;}
             public void setServerAddress_Description( String Val ) {ServerAddress_Description = Val;}
            }
            

            SQL For Table:
            CREATE TABLE [dbo].[ServerAddress](
             [ServerAddress] [int] IDENTITY(1,1) NOT NULL,
             [ServerAddress_ServerAddress] [varchar](256) COLLATE Latin1_General_CS_AI NOT NULL,
             [ServerAddress_Port] [int] NOT NULL,
             [ServerAddress_Description] [varchar](256) COLLATE Latin1_General_CS_AI NULL,
             [ServerAddress_ReturnPath] [varchar](512) COLLATE Latin1_General_CS_AI NOT NULL,
             CONSTRAINT [PK_ServerAddress] UNIQUE NONCLUSTERED
            (
             [ServerAddress] ASC
            )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
            ) ON [PRIMARY]
            



            • 3. Re: 4.2.2 Switching name cases from proper case to camel cas
              jaikiran

              JBoss lets Hibernate (the persistence provider) to handle the JPA entities. I guess, you should post this question in the Hibernate forums. The versions of Hibernate in JBoss-4.0.5 and JBoss-4.2.2 have changed, so maybe that's the reason you don't see this behaviour in 4.0.5

              • 4. Re: 4.2.2 Switching name cases from proper case to camel cas

                The entity names in the WSDL are also being camel cased. Which really makes it look like the issue is in JBoss. If I add tags, I can force most of the names in the WSDL and DB to match the code case, but that requires touching a lot of code. The 4.0.5 version of JBoss did not require these tags to maintain the case on the names. In most of the languages we use to talk to JBoss, case is important.

                Where are the names read out of the jar/ear when a bean is deployed? Could something have been added there to camel case the names?