openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <>
Subject [jira] Commented: (OPENJPA-605) Informix will throw an exception when a unique index is explictily created on the primary key columns
Date Tue, 20 May 2008 20:06:57 GMT


Pinaki Poddar commented on OPENJPA-605:

Agree with Albert's suggestion.
An extra method may not be required though. 

The method implementation in InformixDBDictionary could be:
   public String[] getCreateIndexSQL(Index index) {
      return (isIndexOnThe PrimaryKey(index)) ? new String[0] ? super.getCreateIndexSQL(index);

where isIndexOnThePrimaryKey(index) can encapsulate the logic presented in the patch. 

> Informix will throw an exception when a unique index is explictily created on the primary
key columns
> -----------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-605
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Fay Wang
>         Attachments: openjpa.patch, openjpa.patch
> When an entity is defined as following (unique index annotation on the primary key field.
In this situation): 
> @Entity
> @Table(name="AddressBean")   
> public class AddressBeanAno implements IAddressBean,  Serializable {
>     @EmbeddedId
>     @Index(name="street_index",unique=true)
>     @Column(length=30)
>     private AddressPK street;
> Informix will issue an error:
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Index already exists on
column. {stmnt 1440372186 CREATE UNIQUE INDEX street_index ON AddressBean (street)} [code=-350,
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$3(
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(
> 	at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.createIndex(
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.add(
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.add(
> 	at
> 	at org.apache.openjpa.jdbc.meta.MappingTool.record(
> Per Informaix SQL syntax guide (Create Index section):
> You can not add a unique index to a column or column list that a primary -key constraint
on it. The reason is  that defining the column or column list as the primary key causes the
database server to create a unique internal index on the column or column list. So you cannot
create another unique index on this column or column list with CREATE INDEX statement.   

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message