Hi Marc,
I'd say it's a bug. If you have a JIRA account would you mind opening one at
http://issues.apache.org/jira/browse/OPENJPA ? If not I'll open one on your
behalf.
We already define a longVarChar type for several databases, unfortunately it
doesn't appear to be used anywhere. For Informix the type would be TEXT. I'm
not familiar with LVARCHAR or how it's different from TEXT. Would TEXT also
suffice for you? Either way we have a bug to fix.
In the meantime a quick workaround would be to specify the column type in
the entity. For example :
@Entity
public class MyEntity {
@Id
private int id;
@Basic
@Column(length=4000, columnDefinition="LVARCHAR(4000)")
private String description;
// . . .
Regards,
-mike
Marc.Boudreau wrote:
>
>
>
> Using Openjpa 1.2.1, I found that String fields annotated with @Column
> (length=4000) result in an attempt to create a column with VARCHAR(4000).
> But informix limits the size of VARCHAR to 255. The column should use the
> LVARCHAR type.
>
> MyEntity.java:
> @Entity
> public class MyEntity {
>
> @Id
> private int id;
>
> @Basic
> @Column(length=4000)
> private String description;
>
> public int getId() {
> return id;
> }
>
> public void setId(int value) {
> id = value;
> }
>
> public String getDescription() {
> return description;
> }
>
> public void setDescription(String value) {
> description = value;
> }
> }}
>
> persistence.xml:
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
> version="1.0">
> <persistence-unit name="isvi">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> <class>jpa.test.isvi.MyEntity</class>
> <properties>
> <property name="openjpa.ConnectionDriverName"
> value="com.ibm.db2.jcc.DB2Driver"/>
> <property name="openjpa.ConnectionUserName" value="user
> "/>
> <property name="openjpa.ConnectionPassword" value="
> password"/>
> <property name="openjpa.ConnectionURL"
> value="jdbc:informix-sqli://host:port/db"/>
> <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)"/>
> </properties>
> </persistence-unit>
> </persistence>
>
> When I run the code and attempt to create the EntityManager object, I get
> all of this in the console:
> 2737 isvi INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.1,
> 2951 isvi INFO [main] openjpa.jdbc.JDBC - Using dictionary class
> "org.apache.openjpa.jdbc.sql.InformixDictionary".
> Exception in thread "main" <openjpa-1.2.1-r752877:753278 nonfatal general
> error> org.apache.openjpa.persistence.PersistenceException: IDS SQL Error:
> SQLCODE=-650, SQLSTATE=IX000, SQLERRMC=null, DRIVER=3.51.90 {stmnt
> 809054265 CREATE TABLE MyEntity (id INTEGER NOT NULL, description VARCHAR
> (4000), PRIMARY KEY (id)) LOCK MODE ROW} [code=-650, state=IX000]
> at org.apache.openjpa.jdbc.meta.MappingTool.record
> (MappingTool.java:553)
> at org.apache.openjpa.jdbc.meta.MappingTool.record
> (MappingTool.java:453)
> at
> org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings
> (JDBCBrokerFactory.java:159)
> at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl
> (JDBCBrokerFactory.java:119)
> at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker
> (AbstractBrokerFactory.java:189))
> at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker
> (DelegatingBrokerFactory.java:142)
> at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager
> (EntityManagerFactoryImpl.java:192)
> at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager
> (EntityManagerFactoryImpl.java:145)
> at
> org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager
> (EntityManagerFactoryImpl.java:56))
> at jpa.test.isvi.Main.run(Main.java:12)
> at jpa.test.isvi.Main.main(Main.java:53)
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: IDS SQL
> Error: SQLCODE=-650, SQLSTATE=IX000, SQLERRMC=null, DRIVER=3.51.90 {stmnt
> 809054265 CREATE TABLE MyEntity (id INTEGER NOT NULL, description VARCHAR
> (4000), PRIMARY KEY (id)) LOCK MODE ROW} [code=-650, state=IX000]
> at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap
> (LoggingConnectionDecorator.java:192)
> at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700
> (LoggingConnectionDecorator.java:57),
> at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
> $LoggingConnection$LoggingStatement.executeUpdate
> (LoggingConnectionDecorator.java:762)
> at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate
> (DelegatingStatement.java:114)
> at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL
> (SchemaTool.java:1191)
> at org.apache.openjpa.jdbc.schema.SchemaTool.createTable
> (SchemaTool.java:949)
> at
> org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:526)
> at
> org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:344)
> at
> org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:321)
> at org.apache.openjpa.jdbc.meta.MappingTool.record
> (MappingTool.java:501):
> ... 10 more
>
> As you can see the column definition for description is invalid. If I
> reduce the length of the column 255, everything is OK. I cannot use a
> @Lob
> annotation because this column needs to be searchable. Should this be
> logged as a bug?
>
> Marc Boudreau
> Software Developer
> IBM Cognos Content Manager
> [email protected]
> Phone: 613-356-6412
>
--
View this message in context:
http://n2.nabble.com/Long-strings-are-improperly-mapped-on-Informix-tp4038821p4106473.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.