-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Error Creating Schema if 2 classes are mapped to same table
PostPosted: Tue Dec 09, 2003 2:39 pm 
Newbie

Joined: Fri Aug 29, 2003 2:42 am
Posts: 4
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.