[
https://jira.jboss.org/jira/browse/JBSEAM-3298?page=com.atlassian.jira.pl...
]
Julien Kronegg commented on JBSEAM-3298:
----------------------------------------
We had the same problem (mapping Y/N character to boolean) using the following type
mapping in the seam-gen.reveng.xml file:
<type-mapping>
<sql-type jdbc-type="CHAR" length="1" not-null="true"
hibernate-type="yes_no"/>
</type-mapping>
The corresponding java properties are defined as java.lang.Boolean with the @Column(...),
@NotNull and @Length(max=1) annotations.
Thus, when we do a HQL
"select o from MyObject o where o.myYesNoProperty=true"
the SQL prepared statement is
"select ... from MY_OBJECT where MY_YES_NO_PROPERTY=1"
This is the wrong behavior. The correct behavior would be to generate the following SQL
prepared statement:
"select ... from MY_OBJECT where MY_YES_NO_PROPERTY='Y' "
As Valerie wrote, the correct behavior is obtained by adding the
@Type(type="yes_no") annotation. The @Length annotation is not mandatory (the
expected SQL query is generated whether if the @Length annotation is present or not).
We found references to that "feature" on the web:
-
http://www.seamframework.org/Community/HibernateYesnoForChar1VsSeamgen (Valerie's
original post; I added a reference to this JIRA issue)
-
http://arrogantprogrammer.blogspot.com/2008/02/hibernate-reverse-engineer...
seam-gen doesn't handle hibernate types such as yes_no
------------------------------------------------------
Key: JBSEAM-3298
URL:
https://jira.jboss.org/jira/browse/JBSEAM-3298
Project: Seam
Issue Type: Bug
Components: Tools
Affects Versions: 2.0.3.CR1
Environment: JBoss 4.2.2, DB2, Linux
Reporter: Valerie Griffin
Assignee: Dan Allen
Attachments: EntityHome.java.ftl, GetPropertyAnnotation.ftl
My database has quite a few CHAR(1) entries used as boolean values where the field can
contain Y or N. I defined these entries as hibernate yes_no in the seam-gen.reveng.xml
file, but the code didn't reflect the data type. To work, the field needs to be
annotated with
@Type(type = "yes_no")
and needs to not contain an annotation like:
@Length(max = 1)
If the Type annotation is absent, hibernate detects a schema mismatch. (It expects a
numeric boolean value.)
If there's a Length annotation, the UI's checkbox displays a surprising error
message about the data length.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira