Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi, I am trying to generate a create table statement using schemaexport and ran into this problem.
I thought it is easy to do. Apparently, I am missing something here.
I wanted to create a table with two columns. text_id and state
Text_id: PK
state: enum
I created the EnumUserType as described in
http://www.hibernate.org/272.html
I created the java files and mapping documents like below:
Can you please tell me what i am doing wrong?
Hibernate version: 3.0
Mapping documents:
<?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>
<typedef name="state" class="com.fastx.cafe.RFS.EnumUserType">
<param name="enumClassName">com.fastx.cafe.RFS.State</param>
</typedef>
<class name="com.fastx.cafe.RFS.EnumTest"
table="rfs_test">
<id name="textId" column="text_id" type="int" length="3">
<generator class="increment"/>
</id>
<property name="state" column= "state" type="state"/>
</class>
</hibernate-mapping>
Java Code :
EnumTest.java:
package com.fastx.cafe.RFS;
public class EnumTest {
// primary key
private int textId;
private State state;
public EnumTest() {}
public int getTextId() {
return textId;
}
private void setTextId(int id) {
this.textId = id;
}
public State getState() {
return state;
}
private void setState(State state) {
this.state = state;
}
}
--------------------
State.java:
package com.fastx.cafe.RFS;
public enum State {
NEW,
RECEIVED,
FLUSHED,
CANCELED,
CHANGED;
}
Full stack trace of any exception that occurs:
[schemaexport] Oct 20, 2005 6:59:36 PM org.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: Hibernate 3.0
[schemaexport] Oct 20, 2005 6:59:39 PM org.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: hibernate.properties not found
[schemaexport] Oct 20, 2005 6:59:39 PM org.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: using CGLIB reflection optimizer
[schemaexport] Oct 20, 2005 6:59:39 PM org.hibernate.cfg.Environment <clinit>
[schemaexport] INFO: using JDK 1.4 java.sql.Timestamp handling
[schemaexport] Oct 20, 2005 6:59:47 PM org.hibernate.cfg.Configuration configure
[schemaexport] INFO: configuring from file: hibernate.cfg.xml
[schemaexport] Oct 20, 2005 6:59:50 PM org.hibernate.cfg.Configuration doConfigure
[schemaexport] INFO: Configured SessionFactory: null
[schemaexport] Oct 20, 2005 6:59:51 PM org.hibernate.cfg.Configuration addFile
[schemaexport] INFO: Mapping file: \\mocha\murali\workspace\cafe++\build\classes\com\fastx\cafe\RFS\EnumTest.hbm.xml
[schemaexport] Oct 20, 2005 7:00:01 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[schemaexport] INFO: Mapping class: com.fastx.cafe.RFS.EnumTest -> rfs_test
[schemaexport] Oct 20, 2005 7:00:07 PM org.hibernate.dialect.Dialect <init>
[schemaexport] INFO: Using dialect: org.hibernate.dialect.Oracle9Dialect
[schemaexport] Oct 20, 2005 7:00:12 PM org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing extends queue
[schemaexport] Oct 20, 2005 7:00:12 PM org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing collection mappings
[schemaexport] Oct 20, 2005 7:00:12 PM org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing association property references
[schemaexport] Oct 20, 2005 7:00:12 PM org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing foreign key constraints
[schemaexport] Oct 20, 2005 7:00:18 PM org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing extends queue
[schemaexport] Oct 20, 2005 7:00:18 PM org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing collection mappings
[schemaexport] Oct 20, 2005 7:00:18 PM org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing association property references
[schemaexport] Oct 20, 2005 7:00:18 PM org.hibernate.cfg.Configuration secondPassCompile
[schemaexport] INFO: processing foreign key constraints
BUILD FAILED
build.xml:72: Schema text failed: Could not determine type for: com.fastx.cafe.RFS.EnumUserType, for columns: [org.hibernate.mapping.Column(state)]
Name and version of the database you are using:
Oracle 9.0
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
[url][/url]