-->
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: newbie: enum EnumType.STRING wrong columnlength (oracle)?
PostPosted: Thu Nov 08, 2007 1:07 pm 
Beginner
Beginner

Joined: Tue Nov 06, 2007 5:13 am
Posts: 28
I am using a simple enum (EnumType.STRING) and it works quite as expected.
The only things that seems strange to me are:
  • the generated column is varchar2(255)
    shouldn't the columnlength be only the max. stringlength of my enums?
  • why are no constraints added for the column?
    • is this the way it is meant to be?
    • is this just a problem with the oracle dialect?
    • is this a feature that can/will be added in the future?

Details:
Oracle10g (10.2.0.1.0)
hibernate 3

Enum:
Code:
public enum WebUserStatus {
   REGISTERED,
   ACTIVE
}


entity:
Code:
   
   private WebUserStatus status;

   @Enumerated(EnumType.STRING)
   public WebUserStatus getStatus() {
      return status;
   }

   public void setStatus(WebUserStatus status) {
      this.status = status;
   }


will result in the following column:
status

  • Type: varchar2(255)
  • Length: 255
  • Precision: 19
  • Scale: 2
  • Nullable: true
  • Unique: false


Top
 Profile  
 
 Post subject: Fixing lengths for enum (EnumType.STRING)
PostPosted: Mon Feb 04, 2008 3:18 am 
Newbie

Joined: Thu Dec 28, 2006 5:24 pm
Posts: 14
FWIW... I just add a @Column(length=xx) annotation to my string enumerations... I like your suggestion MUCH better because my approach leaves too much room for error -- but I may choose to increase the length if I anticipate future enum growth and want to avoid a future DDL change.

I also don't think this problem is limited to Oracle... (Did you notice a different behaviour for another database?)

Hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 5:56 am 
Beginner
Beginner

Joined: Tue Nov 06, 2007 5:13 am
Posts: 28
we recently switched to M$-SQL Server, where it doesn't work either


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.