[hibernate-issues] [Hibernate-JIRA] Updated: (HBX-978) unique=true attribute of primary key in generated class prevents the schema to be regenerated

Chris Ofoezie (JIRA) noreply at atlassian.com
Fri Jan 23 07:36:38 EST 2009


     [ http://opensource.atlassian.com/projects/hibernate/browse/HBX-978?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Ofoezie updated HBX-978:
------------------------------

    Attachment: hbx-978.patch

OS: Windows XP SP3,x86 
Database: Oracle Database 10g Express Edition Release 2 (10.2)
Java VM: 1.5.0_16
Hibernate: Branch_3_2_4_SP1_CP
JBoss-4.2.3.GA
JBoss-seam-2.1.1.GA

I experienced the same problem using Jboss & Seam. The problem as described is that when hibernate tools reverse-engineer from oracle the primary key is annotated with 'unique'. When hbm2ddl tries to deploy the schema thie fails as oracle does not allow primary key in combination with unique, yielding the ORA-02261 error code.

This is really important to fix to make Seam usable with oracle.

A possible solution is to not generate the unique constraint on primary keys for oracle (10 at least). I wrote a quick patch against the hibernate core branch that's used in JBoss-4.2.3.GA that works. 

Affected files by the patch:

dialect/Dialect.java
dialect/Oracle10gDialect.java
mapping/Table.java


Regards

Chris Ofoezie

> unique=true attribute of primary key in generated class prevents the schema to be regenerated
> ---------------------------------------------------------------------------------------------
>
>                 Key: HBX-978
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-978
>             Project: Hibernate Tools
>          Issue Type: Bug
>         Environment: OS: Windows Vista 6.0,x86
> Database: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
> Java VM: Java HotSpot(TM) Server VM 1.5.0_11-b03,Sun Microsystems Inc.
> Eclipse Europa: Version: 3.3.0 Build id: I20070621-1340
> HibernateTools-3.2.0.beta10
>            Reporter: Ali Sadik Kumlali
>            Priority: Minor
>         Attachments: hbx-978.patch
>
>
> Hi,
> When I reverse engineer against Oracle, unique=true attribute is added to @Column annotation of primary key column. But, when I generate schema from these generated files, Oracle throws "ORA-02261: such unique or primary key already exists in the table" error.
> I first ran into this situation while trying Seam and posted the problem to Seam's forum:  http://www.jboss.com/index.html?module=bb&op=viewtopic&t=116478. After I got the response, decided to try it without Seam. Then, downloaded the latest HibernateTools & Eclipse Europa and reverse engineered the schema. I saw that generated classes have unique=true attribute which clearly showed that the problem was related with HibernateTools, not with Seam.
> Here is the DDL of the table against which I made my test:
> CREATE TABLE PEOPLE ("ID" NUMBER NOT NULL, "SURNAME" VARCHAR2(50 BYTE), "NAME" VARCHAR2(25 BYTE), CONSTRAINT "PEOPLE_PK" PRIMARY KEY ("ID"));
> Regards,
> Ali Sadik Kumlali

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list