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.  [ 3 posts ] 
Author Message
 Post subject: JDK1.5 Enum Type & SchemaExport
PostPosted: Thu Oct 20, 2005 10:19 pm 
Newbie

Joined: Mon Oct 17, 2005 6:15 pm
Posts: 2
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]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 11:52 am 
Newbie

Joined: Tue Oct 25, 2005 11:47 am
Posts: 1
Does com.fastx.cafe.RFS.EnumUserType implement the UserType interface from package usertype?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 1:34 pm 
Newbie

Joined: Mon Oct 17, 2005 6:15 pm
Posts: 2
Yes. it does implement usertype.

BTW, i found what I did worng. It was working in a standard setup. but not with Eclipse. Then i dig around and i fixed the conf error in eclipse and it is working now. thanks


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