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.