When I add a new string property to an existing hbm mapping, then run hbm2ddl update=true, I get a sybase error.
This works fine with ints and doubles.
Note it doesn't matter what I have the 'not-null' attribute set to in the updated mapping.
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool]
alter table MYQUERYABLEOBJECTS add newField varchar(255)
[hibernatetool]
ERROR Unsuccessful: alter table MYQUERYABLEOBJECTS add newField varchar(255)
[hibernatetool]
ERROR ALTER TABLE 'MYQUERYABLEOBJECTS' failed. Default clause is required in order to add non-NULL column 'newField'.
Hibernate version:
latest
Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="com.test.MyQueryableObject" mutable="true"
table="MYQUERYABLEOBJECTS">
<id name="id" column="id" type="int" unsaved-value="-1">
<generator class="identity"/>
</id>
....
<property name="newField"/> <------- NEW ADDED PROP
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
<hibernatetool destdir=".">
<configuration configurationfile="${xml.root}/com/test/hibernate.cfg.xml"/>
<hbm2ddl
export="true"
update="true"
create="false"
outputfilename="update.sql"
format="true">
</hbm2ddl>
</hibernatetool>
Full stack trace of any exception that occurs:[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] alter table MYQUERYABLEOBJECTS add newField varchar(255)
[hibernatetool] ERROR Unsuccessful: alter table MYQUERYABLEOBJECTS add newField varchar(255)
[hibernatetool] ERROR ALTER TABLE 'MYQUERYABLEOBJECTS' failed. Default clause is required in order to add non-NULL column 'newField'.
Name and version of the database you are using:Sybase ASE 15
The generated SQL (show_sql=true):alter table MYQUERYABLEOBJECTS add newField varchar(255)
Debug level Hibernate log excerpt:[/code]