Hello,
following javax.persistence.@ForeignKey Annotation is ignored by hbm2ddl:
Code:
@JoinColumn(name = "oem_FK", nullable = false, foreignKey = @ForeignKey(name = "parttooem", foreignKeyDefinition = "FOREIGN KEY (oem_FK) references oem (id) ON DELETE RESTRICT"))
@ManyToOne(targetEntity = OEM.class, fetch = FetchType.EAGER, optional = false)
public OEM getOem() {
return oem;
}
Hibernatetool generates:
Code:
alter table Part
add constraint FK25D8138CB60A16
foreign key (oem_FK)
references OEM;
my target is "ON DELETE RESTRICT"
Here is the maven plugin configuration:
Code:
<plugin>
<!-- run "mvn hibernate3:hbm2ddl" to generate a schema -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
</dependencies>
<configuration>
<hibernatetool>
<annotationconfiguration
configurationfile="src/main/resources/META-INF/persistence.xml" />
<hbm2ddl update="true" create="true" export="false"
outputfilename="schema.dll" format="true" console="true" />
</hibernatetool>
<components>
<component>
<name>hbm2ddl</name>
<implementation>jpaconfiguration</implementation>
</component>
</components>
<componentProperties>
<detail>true</detail>
<persistenceunit>my_PU</persistenceunit>
<outputfilename>schema.ddl</outputfilename>
<drop>true</drop>
<create>true</create>
<export>false</export>
<format>true</format>
</componentProperties>
</configuration>
</plugin>
hibernate.cfg.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="MySessionFactory">
<!-- properties -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">false</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.connection.password">password</property>
<property name="current_session_context_class">thread</property>
</session-factory>
</hibernate-configuration>
Versions: hibernate-tools-3.2.4.GA
hibernate-entitymanager-4.3.7.Final
hibernate-core-4.3.7.Final
hibernate-commons-annotations-4.0.5.Final
best regards
Heiko