-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: hbm2ddl 'update' fails on adding a string field in sybase...
PostPosted: Mon May 22, 2006 9:23 pm 
Newbie

Joined: Tue Sep 30, 2003 2:00 pm
Posts: 11
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]


Top
 Profile  
 
 Post subject: Re: hbm2ddl 'update' fails on adding a string field in sybase...
PostPosted: Sat Sep 19, 2009 12:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 11, 2009 2:26 am
Posts: 29
http://opensource.atlassian.com/project ... e/HHH-3621


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.