This content has been marked as final. Show 6 replies
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.
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.
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?
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."
Yes, I can select the value using SQL.Can you select the value using SQL "through TopLink"?
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.
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.