This is a discussion on [Hibernate] yes_no property being mapped as "true"/"false" insteadof "Y"/"N" ?? - JDBC JAVA ; From the log: Hibernate: /* insert collection row com.wholefoods.ittoolkit.ws.ccf.Request.assets */ insert into ITTOOLKIT.CR_ASSET (REQ_ID, ASSET_ENTRY_ID, NAGIOS_DOWNTIME, REBOOT, SYSTEM_TYPE_ID, OS_TYPE_ID) values (?, ?, ?, ?, ?, ?) 12:15:26,546 DEBUG org.hibernate.jdbc.AbstractBatcher:476 - preparing statement 12:15:26,562 DEBUG org.hibernate.type.LongType:133 - binding '41' to parameter: ...
From the log:
Hibernate:
/* insert collection
row com.wholefoods.ittoolkit.ws.ccf.Request.assets */ insert
into
ITTOOLKIT.CR_ASSET
(REQ_ID, ASSET_ENTRY_ID, NAGIOS_DOWNTIME, REBOOT, SYSTEM_TYPE_ID, OS_TYPE_ID)
values
(?, ?, ?, ?, ?, ?)
12:15:26,546 DEBUG org.hibernate.jdbc.AbstractBatcher:476 - preparing
statement
12:15:26,562 DEBUG org.hibernate.type.LongType:133 - binding '41' to
parameter: 1
12:15:26,562 DEBUG org.hibernate.type.StringType:126 - binding null to
parameter: 2
12:15:26,562 DEBUG org.hibernate.type.YesNoType:133 - binding 'true' to
parameter: 3
12:15:26,577 DEBUG org.hibernate.type.YesNoType:133 - binding 'false' to
parameter: 4
12:15:26,577 DEBUG org.hibernate.engine.IdentifierValue:77 - id
unsaved-value strategy UNDEFINED
12:15:26,577 DEBUG org.hibernate.type.StringType:133 - binding 'PRD' to
parameter: 5
12:15:26,577 DEBUG org.hibernate.engine.IdentifierValue:77 - id
unsaved-value strategy UNDEFINED
12:15:26,577 DEBUG org.hibernate.type.StringType:133 - binding 'Windows'
to parameter: 6
The database column is defined as CHAR(1), so of course binding 'true' or
'false' fails with "value too large". Everything I can find on the web and
in JPE about type="yes_no" indicates it will be mapped as "Y" and "N",
not "true" and "false". Is this a bug?
Here's the corresponding mapping:
<bag name="assets" table="CR_ASSET">
<key column="REQ_ID" />
<composite-element class="Asset">
<property name="assetEntryId" column="ASSET_ENTRY_ID" />
<property name="nagiosDowntime" column="NAGIOS_DOWNTIME" type="yes_no" />
<property name="reboot" column="REBOOT" type="yes_no" />
<many-to-one name="systemType" column="SYSTEM_TYPE_ID" fetch="join"
class="com.wholefoods.ittoolkit.ws.code.SystemType"/>
<many-to-one name="osType" column="OS_TYPE_ID" fetch="join"
class="com.wholefoods.ittoolkit.ws.code.OsType"/>
</composite-element>
</bag>