Christian,We've been mapping MySQL ENUMs to a CHAR with the length set to the number of characters in your longest value. So if you have the following MySQL column definition:
Status enum('NEW','PROCESSED') NOT NULL default 'NEW'It would be represented in Torque as:<column default="NEW" name="Status" required="true" size="9" type="CHAR"/>
You then of course also have to add some code in your Torque classes to statically define the ENUM values and to enforce them in the Torque layer.
-Ivor On Nov 25, 2005, at 5:00 AM, Christian Stamm wrote:
Hi, thanks for the answer so far and sorry for the unprecise question. I'd like to know how the SQL ENUM type is implemented. http://dev.mysql.com/doc/refman/4.1/en/enum.html i.e. a column in a database table is allowed to have only n values.My problem is not so much on the java side, but rather how to express itin project-schema.xml. mfg Christian Thomas Fischer wrote:Hi, Assuming you mean java.util.enumeration: As far as I know, enumerations are just an older version ofjava.util.iterator. You would not want to store the iterator in the DB,youusually store the underlying collection. This is in most cases modelled by other tables referenced by a foreign key, which can be accessed in Torquevia a list. Should you need other collection types, they would have to be hand-modelled out of the list. Assuming you mean the new jdk 1.5 enum type:Sorry, JDK 1.5 specific features are not supported yet. You would have toprovide a custom mapper which maps the enum e.g. to an int. You wouldprobably do that best in a mapper class. Then, overload the getter and setter method in the DB object class to accept the enum type, and map theminternally to the int value, which is then stored in the database.Deprecate the original getters and setters to prevent the user from usingthem (I would guess throwing exceptions in the original methods is no good, as they are needed internally by Torque). Thomas"Christian Stamm" <[EMAIL PROTECTED]> schrieb am 24.11.200521:24:13:Hi, I didn't find any documentation on how to declare enumerations inproject-schema.xml. If anyone could post example, that would be fine.Consider this as a noob question, so examples on usage would be also appreciated. thx Christian StammP.S.: After working a little with torque, I'm absolutely impressed. Nicework!-------------------------------------------------------------------- -To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
smime.p7s
Description: S/MIME cryptographic signature
