Re: accessing enum

Mark Matthews <[email protected]>
Newsgroups gmane.comp.db.mysql.java
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jon Drukman wrote:
> Christopher G. Stach II wrote:
>> How is it being retrieved? :)
> 
> Looks like our programmer figured it out:
> 
> "The problem is that we are using EJB3 implemented by Hibernate. We’ve
> got a set of entity beans defined that represent the table structure. I
> was having issues in how I defined the Primary Key class for the
> file_sha1 table entity bean in that I had the type field defined as a
> java Enum that I had written and annotated as a EnumType.STRING. But
> looking at the resultant SQL that was generated by the JBoss container,
> it was using numeric values that corresponded to the java Enum — even
> though the field was annotated with EnumType.STRING. It was driving me
> nuts first that the driver was still using the numeric values and that
> the driver didn’t take into account that the Enum index in MYSQL is
> 1-based and did a 0-based numeric correspondence in the generated SQL. I
> finally found a way of overriding the default behavior and forcing the
> driver to use the string value of the java Enum (thus respecting the
> annotation of EnumType.STRING on the type field in the file_sha1 entity
> bean) and that seems to work."
> 
> Reminds me why I don't do java.
> 
> Thanks for your help!
> -jsd-

Hi Jon,

Just to clarify, the JDBC driver has absolutely nothing to do with this
problem. Your developer is talking about EJB3 "Enumerted Type" mappings
(see section 9.1.21 of the EJB3 persistence specification if you're
curious) to string or numeric values in a database, _not_ the MySQL ENUM
SQL type.

The driver wasn't "still using the numeric values", and certainly didn't
have anything to account for, all the logic you're working with in this
case was within Hibernate's EJB3 implementation (and in fact, EJB3 is
quite unaware of MySQL's ENUM SQL type).

	-Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)

iD8DBQFFSpt5tvXNTca6JD8RAmjWAKCvqJIDhf+UHTgfUOrhriQqeWRakgCfb4zQ
3hBdSHrgZH97Ov3dJyyr3oM=
=auUd
-----END PGP SIGNATURE-----

-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.