Reputation: 61
I do not see any option to do something like, in orm.xml file, of JPA2.
<basic name="developer">
<index />
<column name="developer"/>
</basic>
I see there is hbm.xml files, which offers that, but I wonder if JPA 2.0 really lacks this feature as part of the standard.
so I can avoid the transformation to hbm.xml files...
Upvotes: 3
Views: 571
Reputation: 153780
JPA 2.0 table
XSD type looks like this:
<xsd:complexType name="table">
<xsd:sequence>
<xsd:element name="unique-constraint" type="orm:unique-constraint"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="catalog" type="xsd:string"/>
<xsd:attribute name="schema" type="xsd:string"/>
</xsd:complexType>
While JPA 2.1 looks as follows:
<xsd:complexType name="table">
<xsd:sequence>
<xsd:element name="unique-constraint" type="orm:unique-constraint"
minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="index" type="orm:index"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="catalog" type="xsd:string"/>
<xsd:attribute name="schema" type="xsd:string"/>
</xsd:complexType>
So, you don't have the index
attribute on the table
type that's provided on a per-entity level:
<entity class="Post" access="FIELD">
<table>
<index column-list="first_name,last_name" name="name_idx" unique="true"/>
</table>
<attributes>
...
</attributes>
</entity>
However, you don't need to use hbm2ddl
in your application. Just use Flyway instead and you are way better off.
Upvotes: 1