-->
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: Hibernate Annotations EnumType and Column Type Guessing
PostPosted: Sat Nov 19, 2005 8:22 pm 
Newbie

Joined: Sat Nov 19, 2005 8:07 pm
Posts: 8
I've run into a problem with Hibernate Annotations, persisting 1.5 enums to the database as Strings. I'll stop short of calling it a bug (technically I don't think it is), but it's a real pain.

Basically because Oracle stores identifier names in upper case (unless you quote them at creation time, and really, who does that?), and both the standard and improved naming strategies used by hibernate do not map identifiers to all upper case (nor should they), when EnumType tries to use the metadata to guess the underlying column type for an enum it fails. It doesn't find the column because, while it's perfectly valid to use mixed case in DDL/DML in Oracle, you'd better get the case right when querying for metadata. Sigh.

I saw another post on this earlier today (couldn't find it again, sorry) that mentioned there are similar problems with postgress because it stores everything into lower case.

Anyway, I've worked out what I think is a reasonable solution to the problem. It involves hitting the meta-data up to three times depending on how quickly things are found, and whether the metadata reports it stores thing in upper or lower case or not. It works fine for me, and shouldn't change the behaviour for databases that support mixed case identifiers.

Of course, there are multiple workarounds to this problem. Declare all the column names in the annotations. Or implement a custom naming strategy that upcases all the table and column names. But I think folks other than me will run into this a lot when Hibernate Annotations goes final, so I think it would make sense to solve this in EmumType. If there's agreement then I can happily open a JIRA item and attach a patch to it.

Environment info:
Hibernate version: 3.1RC1
Hibernate Annotations version: 3.1 beta6
Database you are using: Oracle 10g (on Mac OS X no less)

_________________
-Tim Fennell
Stripes: Because web development should just be easier.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 20, 2005 5:24 am 
Newbie

Joined: Mon Nov 01, 2004 6:46 am
Posts: 6
I definitely agree. See my posting in Hibernate Users (sorry, wrong forum:)

http://forum.hibernate.org/viewtopic.php?t=949981

The proposed "work arounds" are annoying and IMHO not in the "spirit" of the simplified EJB3 style...

Sebastian


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 4:18 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hi Tim,
I like your patch, post it here
http://opensource.atlassian.com/project ... se/ANN-148

_________________
Emmanuel


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.