-->
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.  [ 5 posts ] 
Author Message
 Post subject: Schema Update ad two fields in mysql db
PostPosted: Sat Mar 20, 2004 3:50 am 
Newbie

Joined: Sat Jan 31, 2004 9:36 am
Posts: 13
Location: Zurich
Hello,

I want to use the schema update function to add two additional fields to an existing table in mysql. But it doesn't work.

I use
- MySQL 4.0.15
- Hibernate 2.1.2
- mysql-connector-java-3.0.11-stable-bin.jar
- Sun Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
- Suse Linux 9.0

The Ant-Task (net.sf.hibernate.tool.hbm2ddl.SchemaUpdateTask) runs successfull and creates a lot of create table and alter table statements, like:

Code:
...
[schemaupdate] create table SignatureTemplate (id BIGINT NOT NULL AUTO_INCREMENT, versionInDB BIGINT not null, fertigstellungsjahr INTEGER, hauptstudienrichtung VARCHAR(255), diplombereiche VARCHAR(255), forschungOderLehre VARCHAR(255), lastSequenzNummer BIGINT, anlass VARCHAR(255), primary key (id))
[schemaupdate] alter table Praxisdokumentation_AusgefTaetigkeit_Set add index (taetigkeit_id), add constraint FK7B0A110BD76D045B foreign key (taetigkeit_id) references Taetigkeit (id)
...


But the two additional fields are not added in the table.

The table I want to change is:

Code:
create table Arbeit (id BIGINT NOT NULL AUTO_INCREMENT, type VARCHAR(255) not null, versionInDB BIGINT not null, titel VARCHAR(255), untertitel VARCHAR(255), thema VARCHAR(255), abstrakt TEXT, fertigstellungsjahr INTEGER, hauptstudienrichtung_id BIGINT, anlass_id BIGINT, arbeitssignatur VARCHAR(255), mentor_id BIGINT, primary key (id))


The new table definition is:

Code:
create table Arbeit (id BIGINT NOT NULL AUTO_INCREMENT, type VARCHAR(255) not null, versionInDB BIGINT not null, titel VARCHAR(255), untertitel VARCHAR(255), thema VARCHAR(255), abstrakt TEXT, fertigstellungsjahr INTEGER, hauptstudienrichtung_id BIGINT, anlass_id BIGINT, arbeitssignatur VARCHAR(255), mentor_id BIGINT, von INTEGER, bis INTEGER, primary key (id))


So, the new fields are
- von
- bis

So, what can I do to add this two fields to the table "Arbeit"?

Any hints will be helpfull!

Regards
Oliver Nautsch


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 20, 2004 9:30 am 
Newbie

Joined: Sat Jan 31, 2004 9:36 am
Posts: 13
Location: Zurich
Hello,

I'm still trying to add the two additional fields to my table...

After reading in the forum and the documentation I found the property
hibernate.hbm2dll.auto
and added this property to the hibernate.properties file:

Code:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://tiger/DokuStelleDB
hibernate.connection.username=x
hibernate.connection.password=y
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect

hibernate.hbm2ddl.auto=update


But this doesn't solve the problem.

Any ideas?

Regards
Oliver Nautsch


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 20, 2004 9:56 am 
Newbie

Joined: Sat Jan 31, 2004 9:36 am
Posts: 13
Location: Zurich
Hello,

Now, I deleted the tables in the mysql database and after running the schemaupdate-task nothing happend. The database is empty. No tables, nothing.

Is this correct?

Here are the tasks in my ant-script:

Code:
...
       <taskdef
          name="schemaupdate"
           classname="net.sf.hibernate.tool.hbm2ddl.SchemaUpdateTask"
            classpathref="compile.class.path"> 
       </taskdef>      
...

   <target    name="generate.hibernate"
               description="Generates Hibernate class descriptor files."
               depends="compile">               
               
       <!-- Execute the hibernatedoclet task -->
          <hibernatedoclet
                 destdir="${src.dir}"
                 excludedtags="@version,@author,@todo,@TODO"
                 force="true"
                 mergedir="${classes.dir}"
                 verbose="false">
   
              <fileset dir="${src.dir}">
                  <include name="**/*.java"/>
              </fileset>
           
           <hibernate version="2.0" />
           
        </hibernatedoclet>
       
      <copy todir="${classes.dir}">
         <fileset dir="${src.dir}">
               <include name="**/*.hbm.xml"/>
               <include name="**/hibernate.cfg.xml"/>
         </fileset>
        </copy>
   </target>
...
   <target name="generate.hibernate.update"
               depends="generate.hibernate">

         <schemaupdate
                      properties="${classes.dir}/hibernate.properties"
                       quiet="no">
                       <fileset dir="${classes.dir}">
                              <include name="**/*.hbm.xml"/>
                       </fileset>
          </schemaupdate>             
   </target>


Any suggestions, ideas, comments... ?

Regards
Oliver Nautsch


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 20, 2004 2:22 pm 
Newbie

Joined: Sat Jan 31, 2004 9:36 am
Posts: 13
Location: Zurich
Hello,

if I go back to Hibernate 2.1.1 then I get the following messages:

Code:
[schemaupdate] - Running hbm2ddl schema update
[schemaupdate] - fetching database metadata
[schemaupdate] - updating schema

[schemaupdate] - processing one-to-many association mappings
[schemaupdate] - processing one-to-one association property references
[schemaupdate] - processing foreign key constraints
[schemaupdate] create table Praxisdokumentation_AusgefTaetigkeit_Set (praxisdokumentation_id BIGINT not null, taetigkeit_id BIGINT not null, primary key (praxisdokumentation_id, taetigkeit_id))
[schemaupdate] - Unsuccessful: create table Praxisdokumentation_AusgefTaetigkeit_Set (praxisdokumentation_id BIGINT not null, taetigkeit_id BIGINT not null, primary key (praxisdokumentation_id, taetigkeit_id))
[schemaupdate] - General error,  message from server: "Table 'Praxisdokumentation_AusgefTaetigkeit_Set' already exists"
[schemaupdate] create table Arbeit_Diplombereich_Set (arbeit_id BIGINT not null, diplombereich_id BIGINT not null, primary key (arbeit_id, diplombereich_id))
[schemaupdate] - Unsuccessful: create table Arbeit_Diplombereich_Set (arbeit_id BIGINT not null, diplombereich_id BIGINT not null, primary key (arbeit_id, diplombereich_id))
[schemaupdate] - General error,  message from server: "Table 'Arbeit_Diplombereich_Set' already exists"
[schemaupdate] create table Diplombereich (id BIGINT NOT NULL AUTO_INCREMENT, versionInDB BIGINT not null, bezeichnung VARCHAR(255), abkuerzung VARCHAR(255), primary key (id))
[schemaupdate] - Unsuccessful: create table Diplombereich (id BIGINT NOT NULL AUTO_INCREMENT, versionInDB BIGINT not null, bezeichnung VARCHAR(255), abkuerzung VARCHAR(255), primary key (id))
[schemaupdate] - General error,  message from server: "Table 'Diplombereich' already exists"
[schemaupdate] create table Arbeit (id BIGINT NOT NULL AUTO_INCREMENT, type VARCHAR(255) not null, versionInDB BIGINT not null, titel VARCHAR(255), untertitel VARCHAR(255), thema VARCHAR(255), abstrakt TEXT, fertigstellungsjahr INTEGER, hauptstudienrichtung_id BIGINT, anlass_id BIGINT, arbeitssignatur VARCHAR(255), mentor_id BIGINT, von INTEGER, bis INTEGER, primary key (id))
[schemaupdate] - Unsuccessful: create table Arbeit (id BIGINT NOT NULL AUTO_INCREMENT, type VARCHAR(255) not null, versionInDB BIGINT not null, titel VARCHAR(255), untertitel VARCHAR(255), thema VARCHAR(255), abstrakt TEXT, fertigstellungsjahr INTEGER, hauptstudienrichtung_id BIGINT, anlass_id BIGINT, arbeitssignatur VARCHAR(255), mentor_id BIGINT, von INTEGER, bis INTEGER, primary key (id))
[schemaupdate] - General error,  message from server: "Table 'Arbeit' already exists"
...


Any help....

Regards
Oliver Nautsch


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 20, 2004 3:57 pm 
Newbie

Joined: Sat Jan 31, 2004 9:36 am
Posts: 13
Location: Zurich
Hello,

I solved the problem!

The problem and the solution is described in
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-409

So I patched Hibernate 2.1.2 and it rocks...

Regards
Oliver Nautsch


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.