Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-19174

[GSS](7.2.z) Auto generated aliases exceed the limit length set by SybaseASE157Dialect

    Details

    • Type: Bug
    • Status: New (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 7.2.z.GA
    • Fix Version/s: None
    • Component/s: Documentation, Hibernate
    • Labels:
      None
    • Target Release:
    • Steps to Reproduce:
      Hide

      1. Build attached application for reproduction sybase-alias-reproducer.zip

      cd sybase-alias-reproducer
      mvn package
      cp target/sybase-alias-reproducer.war $JBOSS_HOME/standalone/deployments/
      

      2. Create a dummy entity via application's REST endpoint

      curl -XPOST localhost:8080/sybase-alias-reproducer/api/data
      {"id":1,"sampleFlag":false,"sampleName":"testname-1"}
      

      3. Fetching the entity created in the previous step throws com.sybase.jdbc4.jdbc.SybSQLException ... Maximum length is 30.

      curl -XGET localhost:8080/sybase-alias-reproducer/api/data/1
      
      Show
      1. Build attached application for reproduction sybase-alias-reproducer.zip cd sybase-alias-reproducer mvn package cp target/sybase-alias-reproducer.war $JBOSS_HOME/standalone/deployments/ 2. Create a dummy entity via application's REST endpoint curl -XPOST localhost:8080/sybase-alias-reproducer/api/data { "id" :1, "sampleFlag" : false , "sampleName" : "testname-1" } 3. Fetching the entity created in the previous step throws com.sybase.jdbc4.jdbc.SybSQLException ... Maximum length is 30. curl -XGET localhost:8080/sybase-alias-reproducer/api/data/1
    • Workaround Description:
      Hide

      Create a custom Dialect like below:

      public class MySybaseDialect extends SybaseASE157Dialect {
          @Override
          public int getMaxAliasLength() {
              return 10;  // same as org.hibernate.dialect.SybaseDialect
          }
      }
      

      Then apply custom dialect to persistence.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.2"
                   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
          <persistence-unit name="Sybase" transaction-type="JTA">
              <jta-data-source>java:jboss/datasources/Sybase</jta-data-source>
              <properties>
                  <!-- workaround - custom dialect which return getMaxAliasLength 10 same as org.hibernate.dialect.SybaseDialect -->
                  <property name="hibernate.dialect" value="com.redhat.cee.example.dialect.MySybaseDialect"/>
              </properties>
          </persistence-unit>
      </persistence>
      
      Show
      Create a custom Dialect like below: public class MySybaseDialect extends SybaseASE157Dialect { @Override public int getMaxAliasLength() { return 10; // same as org.hibernate.dialect.SybaseDialect } } Then apply custom dialect to persistence.xml: <?xml version= "1.0" encoding= "UTF-8" ?> <persistence xmlns= "http: //xmlns.jcp.org/xml/ns/persistence" xmlns:xsi= "http: //www.w3.org/2001/XMLSchema-instance" version= "2.2" xsi:schemaLocation= "http: //xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd" > <persistence-unit name= "Sybase" transaction-type= "JTA" > <jta-data-source>java:jboss/datasources/Sybase</jta-data-source> <properties> <!-- workaround - custom dialect which return getMaxAliasLength 10 same as org.hibernate.dialect.SybaseDialect --> <property name= "hibernate.dialect" value= "com.redhat.cee.example.dialect.MySybaseDialect" /> </properties> </persistence-unit> </persistence>

      Description

      If an Entity with a field name of nearly 30 characters is deployed, the alias generated by Hibernate will exceed 30 characters and the following exception will occur:

      12:23:52,034 INFO  [stdout] (default task-1) Hibernate: select sampletabl0_.id as id1_0_0_, sampletabl0_.sampleFlag as sampleFlag2_0_0_, sampletabl0_.samplenameabcdeabcdeabcdeabc as samplenameabcdeabcdeabcdeabc3_0_0_ from SampleTableData sampletabl0_ where sampletabl0_.id=?
      12:23:52,068 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-1) SQL Error: 103, SQLState: ZZZZZ
      12:23:52,068 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-1) The identifier that starts with 'samplenameabcdeabcdeabcdeabc3_' is too long. Maximum length is 30.
      
      12:23:52,070 INFO  [org.hibernate.event.internal.DefaultLoadEventListener] (default task-1) HHH000327: Error performing load command : org.hibernate.exception.GenericJDBCException: could not extract ResultSet
      12:23:52,090 ERROR [org.jboss.as.ejb3.invocation] (default task-1) WFLYEJB0034: EJB Invocation failed on component SampleTableDataResource for method public com.redhat.cee.example.entity.SampleTableData com.redhat.cee.example.rs.SampleTableDataResource.get(long): javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
      ...
      Caused by: com.sybase.jdbc4.jdbc.SybSQLException: The identifier that starts with 'samplenameabcdeabcdeabcdeabc3_' is too long. Maximum length is 30.
      
      	at com.sybase.jdbc4.tds.Tds.processEed(Tds.java:4201)
      	at com.sybase.jdbc4.tds.Tds.nextResult(Tds.java:3318)
      	at com.sybase.jdbc4.jdbc.ResultGetter.nextResult(ResultGetter.java:78)
      	at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:302)
      	at com.sybase.jdbc4.jdbc.SybStatement.nextResult(SybStatement.java:284)
      	at com.sybase.jdbc4.jdbc.SybStatement.queryLoop(SybStatement.java:2655)
      	at com.sybase.jdbc4.jdbc.SybStatement.executeQuery(SybStatement.java:2641)
      	at com.sybase.jdbc4.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:274)
      	at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:504)
      	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:60)
      	... 150 more
      

      Environment:

      • JBoss EAP 7.2.7
      • SAP Adaptive Server Enterprise/16.0 SP03
      • jConnect (TM) for JDBC(TM)/16.0 SP03 PL02 (Build 27403)/P/EBF27518/JDK 1.6.0/jdbcmain/OPT/Mon Aug 28 18:41:14 PDT 2017
      • org.hibernate.dialect.SybaseASE157Dialect

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  amehendal Ashwin Mehendale
                  Reporter:
                  norito.agetsuma Norito Agetsuma
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated: