Hibernate Xdoclet many-to-one generates dulicate unique=”true” – SOLVED!

While working on my degree project i came across a situation where i needed a one-to-one relationship. Among the two methods to implement such relationship in hibernate, i choose to use the foreign-key method other than the shared primary key method.

I was unable to do a schemaExport because of xdoclet generating two unique=”true” attributes in the .hbm file.

Google found me this link http://opensource.atlassian.com/projects/xdoclet/browse/XDT-1665 where it is reported as a bug which is open at the time of writing.

After playing around with it for some time i figured out that by adding a @hibernate.column would stop Xdoclet generating two unique=”true” attributes which in turn is converted to the mapping xml file which becomes invalid according to the hibernate-3.0.dtd.

Initial xdoclet tag was.

@hibernate.many-to-one
class=”someClass”
unique=”true”

I was able to get rid of this error by adding a column and setting the unique-key.
@hibernate.many-to-one
class=”someClass”
unique=”true”
foreign-key=”myFK”
@hibernate.column
name=”fkColumn”
unique-key=”myFK”

Advertisements

One thought on “Hibernate Xdoclet many-to-one generates dulicate unique=”true” – SOLVED!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s