Env:
Hibernate 2.1.2,
Mysql Connector/J 3.0.10-stable
hibernate.hbm2ddl.auto = update
new columns are correctly added.
Every run hibernate try to readd all the indexes (costraint) but the indexes are already there. Is this a bug or I'm missing something?
hibernate.hbm2ddl.auto = create
If the tables already exists hibernate will drop them even if I use only create and not create-drop.
Again: anyone else experiencing this?
Here is an example mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="mydomain.model.Page" table="pages">
<id name="id" column="id" type="long">
<generator class="native"/>
</id>
<many-to-one name="site" class="mydomain.model.Site" column="siteid" not-null="true"/>
<property name="orderId" column="orderid" type="integer" />
<property name="shortName" column="shortname" type="string" length="32"/>
<!-- property name="longName" column="longname" type="string" / -->
<property name="pageType" column="pagetype" type="string" length="16"/>
<property name="status" column="status" type="integer" not-null="true"/>
<set name="contents" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="pageid"/>
<one-to-many class="mydomain.model.Content"/>
</set>
</class>
</hibernate-mapping>
And the DDL:
Code:
drop table if exists pages
create table pages (
id BIGINT NOT NULL AUTO_INCREMENT,
siteid BIGINT not null,
orderid INTEGER,
shortname VARCHAR(32),
pagetype VARCHAR(16),
status INTEGER not null,
primary key (id)
)
alter table pages add index (siteid), add constraint FK657EFC4CA3B36A2 foreign key (siteid) references sites (id)