-->
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.  [ 4 posts ] 
Author Message
 Post subject: Enums: Back to JDK 1.4 from Java 5
PostPosted: Thu Jul 31, 2008 3:07 pm 
Beginner
Beginner

Joined: Tue Aug 01, 2006 4:57 am
Posts: 25
HI

Due to client restrictions I've to rewrite part of my code which was earlier written in Java 5, now in java 1.4. I was using java 5 enums with hibernate. For example,

Java 5 enum:

Code:
public enum AType{
SHOW,HIDE;
}


AType is a property of some java bean A.

in the hbm file I have:
Code:
<hibernate-mapping auto-import="true" default-lazy="false">
   <typedef name="AType" class='GenericEnumUserType'>
            <param name="enumClass">AType</param>
     </typedef>
   
   <class name="A" table="a">
      <property name="aType" type="AType" column="aType"/>
   </class>
</hibernate-mapping>


Everything was working fine in java 5, now, how do I move the same functionality to 1.4? Pls help[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 01, 2008 1:58 pm 
Beginner
Beginner

Joined: Tue Aug 01, 2006 4:57 am
Posts: 25
any help on this pls.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 01, 2008 4:11 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Well, without support for enums, you'll have to create your own custom class, perhaps one that simulates the Java 5 enum behavior. Then map that class to your database table using your mapping file. Google for Java 1.4 enum implementation, and you'll find plenty of strategies.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 02, 2008 10:32 pm 
Beginner
Beginner

Joined: Tue Aug 01, 2006 4:57 am
Posts: 25
Thanks for the reply, i thought the same.. created a class with static variables. that solved the problem.


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