Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:2.18
Mapping documents:<hibernate-mapping>
<class name="com.ipds.persistence.ContactType" table="CONTACT_TYPE">
<meta attribute="class-description">
</meta>
<id name="id" type="long" column="CONTACT_TYPE_ID">
<meta attribute="scope-set">protected</meta>
<meta attribute="field-description">Unique identity - automatically generated</meta>
<generator class="native" />
</id>
<property name="type" type="string">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="field-description">The contact type</meta>
<column name="CONTACT_TYPE" length="40" not-null="true" />
</property>
<property name="lastSaved" type="timestamp">
<meta attribute="field-description">The contact last saved date</meta>
<column name="LAST_SAVED" not-null="true" />
</property>
</class>
</hibernate-mapping>
This is my ant target that I use to generate the ddl for our project. And below is a sample of a typical table create sql statement that is produced. The problem is afterwards I have to insert the sequence sql by hand. Is there a way to do have hiberate do this for me? thanks
Scott
<target name="generate-ddl" depends="copy-mapping" description="generate ddl file">
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd_hh-mm-ss" />
</tstamp>
<copy file="${basedir}/ddl/ipds-schema.ddl" toFile="${basedir}/ddl/ipds-schema_${timestamp}.ddl" />
<java classname="net.sf.hibernate.tool.hbm2ddl.SchemaExport" fork="true" dir=".">
<arg line="--config=/config/hibernate_ipds.cfg.xml --output=${basedir}/ddl/ipds-schema.ddl --format --text --delimiter=;" />
<classpath refid="hibernate.tools.classpath" />
</java>
</target>
generated sql
create table CONTACT_TYPE (
CONTACT_TYPE_ID int8 not null ,
CONTACT_TYPE varchar(40) not null,
LAST_SAVED timestamp not null,
primary key (CONTACT_TYPE_ID)
);
massaged sql
create table CONTACT_TYPE (
CONTACT_TYPE_ID int8 not null DEFAULT nextval('public.hibernate_sequence'::text),
CONTACT_TYPE varchar(40) not null,
LAST_SAVED timestamp not null,
primary key (CONTACT_TYPE_ID)
);