-->
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: Schemaexport generates extra column when using a Date field
PostPosted: Thu Jun 09, 2005 3:18 pm 
Newbie

Joined: Thu Jun 09, 2005 2:49 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.1

Mapping documents:

hibernate.cfg.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated file - Do not edit! -->

<hibernate-configuration>

   <!-- a SessionFactory instance listed as /jndi/name -->
   <session-factory>

      <!-- properties -->
      <property name="connection.datasource">java:env/comp/psfeed/AdminDS</property>
      <property name="dialect">org.hibernate.dialect.OracleDialect</property>
      <property name="show_sql">false</property>
      <property name="use_outer_join">false</property>

      <!-- mapping files -->
      <mapping resource="com/cingular/clarify/synchronization/peoplesoft/db/ErrorReport.hbm.xml"/>

   </session-factory>

</hibernate-configuration>


ErrorReport.hbm.xml:
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
>
    <class
        name="com.cingular.clarify.synchronization.peoplesoft.db.ErrorReport"
    >

        <id
            name="id"
            column="id"
            type="int"
        >
            <generator class="sequence">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-ErrorReport.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <many-to-one
            name="session"
            class="com.cingular.clarify.synchronization.peoplesoft.db.Session"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="sessionId"
        />

        <property
            name="errorDate"
            type="java.util.Date"
            update="true"
            insert="true"
            column="errorDate"
        />

        <property
            name="cuid"
            type="java.lang.String"
            update="true"
            insert="true"
            column="cuid"
            length="6"
        />

        <property
            name="message"
            type="java.lang.String"
            update="true"
            insert="true"
            column="message"
            length="255"
        />

        <property
            name="details"
            type="java.lang.String"
            update="true"
            insert="true"
            column="details"
            length="4096"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-ErrorReport.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Name and version of the database you are using:
Oracle 10

The generated DDL:
Code:
create table ErrorReport (
   id number(10,0) not null,
   sessionId number(10,0),
   errorDate date,
   cuid varchar2(6),
   message varchar2(255),
   details long,
   date number(10,0),
   primary key (id)
);


Source code

ErrorReport.java
Code:
package com.cingular.clarify.synchronization.peoplesoft.db;

import java.util.Date;

/**
* Class to represent a reject status change record.
* @hibernate.class
*/
public class ErrorReport {
   private int id;
   private Session session;
   private Date errorDate;
   private String cuid;
   private String message;
   private String details;

   /**
    * Constructor for a new error report.
    *
    * @param session The session the reported error occurred in.
    * @param errorDate The date/time stamp of the error.
    * @param cuid The affected CUID. Null if none.
    * @param message the message.
    * @param details the details
    */
   public ErrorReport( Session session, Date errorDate, String cuid, String message, String details ) {
      this.session = session;
      this.errorDate = errorDate;
      this.cuid = cuid;
      this.message = message;
      this.details = details;
   }

   /**
    * @hibernate.id generator-class="sequence"
    */
   public int getId() {
      return id;
   }

   /**
    * setter for id.
    */
   void setId(int id) {
      this.id = id;
   }

   /**
    * @hibernate.many-to-one column="sessionId"
    */
   public Session getSession() {
      return session;
   }

   /**
    * setter for session.
    */
   void setSession(Session session) {
      this.session = session;
   }

   /**
    * @hibernate.property
    */
   public Date getErrorDate() {
      return errorDate;
   }

   /**
    * setter for errorDate.
    */
   void setErrorDate(Date errorDate) {
      this.errorDate = errorDate;
   }

   /**
    * @hibernate.property length="6"
    */
   public String getCuid() {
      return cuid;
   }

   /**
    * setter for cuid.
    */
   void setCuid(String cuid) {
      this.cuid = cuid;
   }

   /**
    * @hibernate.property length="255"
    */
   public String getMessage() {
      return message;
   }

   /**
    * setter for message.
    */
   void setMessage(String message) {
      this.message = message;
   }

   /**
    * @hibernate.property length="4096"
    */
   public String getDetails() {
      return details;
   }

   /**
    * setter for details.
    */
   void setDetails(String details) {
      this.details = details;
   }
}


The problem:

SchemaExport is creating a second column named "date" in the schema. This only happens if I do not name the column "date" if I name it "date" instead of "errorDate" it does not create the extra column. However, since "date" is a reserved word in oracle's brand of SQL, I get an invalid column name error when I create the tables.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 14, 2005 1:37 pm 
Newbie

Joined: Thu Jun 09, 2005 2:49 pm
Posts: 6
I have continued to try and diagnos this problem but to no avail. I have discoverd one thing that I found intersting. I have another table with two date fields in it that are not suffering from this issue. In that case the fields are named 'start' and 'end' and denote a start and ending time. The fields are specified and mapped in exactly the same way.

This seems like a really esoteric bug, I am going to try and find some time to debug the schema export tool to see what could be causeing this.


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.