You are reading Hibernate and CHAR(%n) mapping. You can leave a comment or trackback this post.
Posted on February 24th, 2008 by Skaber.
Categories: Programming.
By default, Hibernate seems to map CHAR(%n) database fields to java.lang.String. It causes no problem when querying a database without comparing this field, but unfortunately, the query may fail if the String does not containt %n chars. To avoid any problem, I suggest using VARCHAR(%n) fields where %n is the max size that can have your string. If you prefer to keep CHAR(%n) fields, probably for performance matters, refer to the hibernate documentation to specify a type such as “type=CharArray’” in your mapping.
The consequence of automatically mapping a database chararray field to a String object in java causes the impossibility of using this field in WHERE clauses.
0 comments.
Comments can contain some xhtml. Names and emails are required (emails aren't displayed), url's are optional.