openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Boudreau <Marc.Boudr...@ca.ibm.com>
Subject Long strings are improperly mapped on Informix
Date Fri, 20 Nov 2009 16:21:25 GMT


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
marc.boudreau@ca.ibm.com
Phone: 613-356-6412
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message