[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2429) SQL Character Types Incorrectly mapped to Java objects
Chris Wilson (JIRA)
noreply at atlassian.com
Fri Mar 12 05:35:47 EST 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35814#action_35814 ]
Chris Wilson commented on HHH-2429:
-----------------------------------
Ditto. We need to support fixed-length CHAR fields for our application. But MySQL dialects force all CHAR fields to be length 1:
{code:title=MySQLDialect.MySQLDialect()}
registerColumnType( Types.CHAR, "char(1)" );
{code}
whereas VARCHAR is allowed to have any length:
{code:title=MySQLDialect.registerVarcharTypes()}
registerColumnType( Types.VARCHAR, 255, "varchar($l)" );
{code}
We have to create a [subclass dialect|http://rita.wfplogistics.org/trac/browser/rita/src/org/wfp/rita/db/FixedMysqlDialect.java] to fix this.
> SQL Character Types Incorrectly mapped to Java objects
> ------------------------------------------------------
>
> Key: HHH-2429
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2429
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.2.1
> Environment: Hibernate 3.2.1, Oracle10g
> Reporter: Tyler Van Gorder
> Original Estimate: 15 minutes
> Remaining Estimate: 15 minutes
>
> We have a work flow that allows the user to enter an arbitrary SQL statement to be executed by our application. We pass those queries through session.createSQLQuery().
> We ran into a problem with String literals, which are reported by Oracle (ResultSetMetaData) to be CHAR. Reading the JDBC API, CHAR is a fixed length string. Hibernate is incorrectly mapping this to a Character field. We ended up overriding the Oracle dialect with our own as follows:
> In our constructor, for a dialect that extends Oracle9iDialect:
> super()
> registerColumnType(Types.CHAR, "char($l)" );
> registerHibernateType( Types.CHAR, Hibernate.STRING.getName() );
> The HibernateType is the crucial one and we are overriding the behavior in the base "Dialect" class, so this appears that it would be a problem for all database variants that don't explicitly change this.
> Thanks.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list