Hibernate version: 3.2.1.GA
Name and version of the database you are using: MySQL 5.0.24
I have a super-class A that defines a 'name' property that is inherited by 2 sub-classes: GlobalA and LocalA. I would like for GlobalA to define this column as unique, but I can't seem to find the right way to do it.
First, I tried overriding the getResourceName() method in GlobalA, copying the annotations from the parent, and adding an '@Column(unique=true)', but I get an error during schema generation indicating that GlobalA has defined a duplicate property 'name'.
Next, I tried defining the unique constraint via the @Table annotation in GlobalA:
uniqueConstraints = { @UniqueConstraint(columnNames = { "resourceName" }) }
This results a NPE during schema generation (I can provide stack trace, if desired).
I'm not very familiar with @AttributeOverride. Is this the way to go?
For what it's worth, GlobalA is not intended to be a concrete class, so if I could use a property-specific annotation (@Column preferred over @Table), then that would definitely be preferred to duplicating the unique constraint in each concrete sub-class, but at this point I'll be happy with just about anything short of manually defining this via a SQL script.
Any help would be greatly appreciated.
-Trey
|