This discussion is archived
6 Replies Latest reply: Feb 23, 2012 7:22 AM by 914447 RSS

Toplink varchar (Sybase) limit to 255 characters

914447 Newbie
Currently Being Moderated
I am using Toplink 11g JPA to obtain pojos from a Sybase ASE (version 15) table. This programs run in Tomcat 6.0.14 on a Linux OS.

Each pojo represents a displayed row in a grid in the browser. After redisplaying the same 10 rows of pojos (with one column/field of size 500-600 characters) about three times successfully, the returned pojo column size is restricted to 255 characters.

I tried to set the annotation for column length to 1000, but it does not seem to care.

Any suggestions/ideas?
  • 1. Re: Toplink varchar (Sybase) limit to 255 characters
    cdelahun Pro
    Currently Being Moderated
    Hello,

    The column length within the annotation only affects DDL generation, so check what is used when the table is created - the default varchar size on the SybasePlatform class comes from the DatabasePlatform class and seems to be 255. Be sure you are dropping and recreating the tables when you make changes to the size so that the DDL is rerun on the database. Chances are that it is just the column size in the database table that is causing the trunctation. The cache will show the value initially set until it gets refreshed from the cache - which might explain why you only see this problem later on and not immediately. You can verify by calling persist, flush then refresh and check the string size.

    If that is not the problem, TopLink/EclipseLink will not truncate data, so you will need to try and narrow when it is occuring. You might want to check that your JDBC driver allows inserting a string longer than 255 characters and that it will return the same string through a straight JDBC test case to rule that out as a cause.

    Best Regards,
    Chris
  • 2. Re: Toplink varchar (Sybase) limit to 255 characters
    914447 Newbie
    Currently Being Moderated
    The database table column length is 3000 characters.

    JDBC query returns the entire string (between 550 - 600 characters) all the time.

    The problem seems to be between the database and JPA.

    Any other suggestions would be appreciated.
  • 3. Re: Toplink varchar (Sybase) limit to 255 characters
    JamesSutherland Pro
    Currently Being Moderated
    TopLink does not do any truncation. Check the value on the database.
    Also check that you are not truncating it in you get/set methods, or through an event.

    Try selecting the value using a native SQL query. Does it get truncated?
  • 4. Re: Toplink varchar (Sybase) limit to 255 characters
    914447 Newbie
    Currently Being Moderated
    Yes, I can select the value using SQL.

    Noticed something else, I have another installation of Sybase (same version; tables and fields create with same script) that runs this exact same scenario using the exact same software, toplink, java code, etc. without any problem. I get all 550 characters each time. The only difference could be was how the database was installed/configured (excluding the tables, permission, users).

    Does toplink have some specific db configuration requirements? I did noticed that the database that works has "Stores mixed case identifiers" and "Support mixed case identifiers" set to "No" when comparing in DBVisual. Whereas, the non-working Sybase installation has this value set to "Invalid State."

    Any ideas?
  • 5. Re: Toplink varchar (Sybase) limit to 255 characters
    JamesSutherland Pro
    Currently Being Moderated
    Yes, I can select the value using SQL.
    Can you select the value using SQL "through TopLink"?

    i.e. session.executeSQL(sql);

    Do you get the truncation?

    If you do, then also try through raw JDBC.

    If you don't, then the truncation is occurring in the mapping, perhaps in your set method.
  • 6. Re: Toplink varchar (Sybase) limit to 255 characters
    914447 Newbie
    Currently Being Moderated
    Found the solution. It was the JDBC Driver version. We had both jconn2.jar and jconn3.jar in the WEB-INF/lib directory. jconn2.jar is version 5.5 - this version restricted varchar to 255 characters. jconn3.jar is version 6.0 removed that restriction.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points