In our object model, two objects have same attributes, so we are trying to persist in the same table. When I map these objects to the same table, the schema generation tool creates a CREATE TABLE statement using all the properties from each of this class definition. This causes the SQL statement to contain duplicate names.
Example
1) Hibernate Mapping: I am listing only subset of the attributes
<class name="Document" table="DOCUMENT_MASTER" dynamic-update="true">
<id name="ObjectId" type="string" column="document_id">
<generator class="assigned"/>
</id>
<property name="ObjectType" type="string">
<column name="object_type" sql-type="varchar2(256)" not-null="true"/>
</property>
<property name="ObjectName" type="string">
<column name="document_name" sql-type="varchar2(256)" not-null="true"/>
</property>
</class>
<class name="CompoundDocument" table="DOCUMENT_MASTER" dynamic-update="true">
<id name="ObjectId" type="string" column="document_id">
<generator class="assigned"/>
</id>
<property name="ObjectType" type="string">
<column name="object_type" sql-type="varchar2(256)" not-null="true"/>
</property>
<property name="ObjectName" type="string">
<column name="document_name" sql-type="varchar2(256)" not-null="true"/>
</property>
</class>
2) Schema Generation Script (hbm2ddl)
[java] create table DOCUMENT_MASTER (document_id VARCHAR2(255) not null, object_type varchar2(256) not null, document_name varchar2(256) not null, document_id VARCHAR2(255) not null, document_name VARCHAR2(255), object_type VARCHAR2(255), primary key (document_id))
[java] Unsuccessful: ORA-00957: duplicate column name
|