I've got a strange problem where a UserType (TimeZoneUserType) is returning a null value from the database even though I can see clearly that the value in the database is set to "Eastern". My TimeZone and TimeZoneUserType classes are pretty vanilla and the same pattern is working for other persistent types. To make this even more interesting, we've found that by moving the <property> definition higher up in our mapping file, that this user type suddenly begins working with no changes. Having debugged into the code to try to determine what's going on, I noticed a lot of outer joins in the sql (below) and wondered if somehow that is causing certainly columns to be filled with nulls inappropriately.
Has anyone else encountered or does anyone know a good solution for this kind of problem? The specifics are below.
Thanks,
Dave
Hibernate version: 2.1.7
Java Version: 1.5.0_02
Mapping documents: <snippet>
<property
name="TimeZone"
update="true"
insert="true"
access="property"
column="time_zone"
type="com.enttek.ems.shared.model.enumeration.TimeZoneUserType"
/>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
No stack trace available - no error thrown.
Name and version of the database you are using: MySQL 3.23
The generated SQL (show_sql=true):
select site0_.id as id8_, site0_.name as name8_, site0_.site_code as site_code8_, site0_.home_circuit_id as home_cir4_8_, site0_.circuit_district as circuit_5_8_, site0_.circuit_region as circuit_6_8_, site0_.dma_id as dma_id8_, site0_.tech_region_id as tech_reg8_8_, site0_.sales_region_id as sales_re9_8_, site0_.metro_area_id as metro_a10_8_, site0_.physical_address_id as physica11_8_, site0_.mailing_address_id as mailing12_8_, site0_.showtime_number as showtim13_8_, site0_.showtime_extension as showtim14_8_, site0_.main_number as main_nu15_8_, site0_.main_extension as main_ex16_8_, site0_.mobile_number as mobile_17_8_, site0_.mobile_extension as mobile_18_8_, site0_.office_number as office_19_8_, site0_.office_extension as office_20_8_, site0_.fax_number as fax_number8_, site0_.fax_extension as fax_ext22_8_, site0_.evening_price as evening23_8_, site0_.matinee_price as matinee24_8_, site0_.time_zone as time_zone8_, site0_.active_date as active_26_8_, site0_.inactive_date as inactiv27_8_, site0_.modified_date as modifie28_8_, site0_.deleted as deleted8_, site0_.created_timestamp as created30_8_, site0_.deleted_timestamp as deleted31_8_, circuit1_.id as id0_, circuit1_.name as name0_, circuit1_.modified_date as modified3_0_, circuit1_.deleted as deleted0_, circuit1_.created_timestamp as created_5_0_, circuit1_.deleted_timestamp as deleted_6_0_, dma2_.id as id1_, dma2_.name as name1_, dma2_.modified_date as modified3_1_, dma2_.deleted as deleted1_, dma2_.created_timestamp as created_5_1_, dma2_.deleted_timestamp as deleted_6_1_, techregion3_.id as id2_, techregion3_.name as name2_, techregion3_.modified_date as modified3_2_, techregion3_.deleted as deleted2_, techregion3_.created_timestamp as created_5_2_, techregion3_.deleted_timestamp as deleted_6_2_, salesregio4_.id as id3_, salesregio4_.region_name as region_n2_3_, salesregio4_.modified_date as modified3_3_, salesregio4_.deleted as deleted3_, salesregio4_.created_timestamp as created_5_3_, salesregio4_.deleted_timestamp as deleted_6_3_, metroarea5_.id as id4_, metroarea5_.name as name4_, metroarea5_.modified_date as modified3_4_, metroarea5_.deleted as deleted4_, metroarea5_.created_timestamp as created_5_4_, metroarea5_.deleted_timestamp as deleted_6_4_, address6_.id as id5_, address6_.address_line1 as address_2_5_, address6_.address_line2 as address_3_5_, address6_.city as city5_, address6_.state_id as state_id5_, address6_.county as county5_, address6_.postal_code as postal_c7_5_, address6_.country_id as country_id5_, address6_.modified_date as modified9_5_, address6_.deleted as deleted5_, address6_.created_timestamp as created11_5_, address6_.deleted_timestamp as deleted12_5_, state7_.id as id6_, state7_.name as name6_, state7_.short_code as short_code6_, state7_.country_id as country_id6_, state7_.modified_date as modified5_6_, state7_.deleted as deleted6_, state7_.created_timestamp as created_7_6_, state7_.deleted_timestamp as deleted_8_6_, country8_.id as id7_, country8_.code as code7_, country8_.short_code as short_code7_, country8_.name as name7_, country8_.modified_date as modified5_7_, country8_.deleted as deleted7_, country8_.created_timestamp as created_7_7_, country8_.deleted_timestamp as deleted_8_7_ from site site0_ left outer join circuit circuit1_ on site0_.home_circuit_id=circuit1_.id left outer join dma dma2_ on site0_.dma_id=dma2_.id left outer join tech_region techregion3_ on site0_.tech_region_id=techregion3_.id left outer join sales_region salesregio4_ on site0_.sales_region_id=salesregio4_.id left outer join metro_area metroarea5_ on site0_.metro_area_id=metroarea5_.id left outer join address address6_ on site0_.physical_address_id=address6_.id left outer join state state7_ on address6_.state_id=state7_.id left outer join country country8_ on address6_.country_id=country8_.id where site0_.id=?
Debug level Hibernate log excerpt:
|