How to make Hibernate query ignore white spaces ?

172 views
Skip to first unread message

moonshi

unread,
Aug 12, 2011, 11:34:56 AM8/12/11
to nhu...@googlegroups.com
Hi:

I am very new to this forum and a rookie using NHibernate.
We came up with a situation recently and I would appreciate someone's help in that.

We have two entities having parent-child relation. Here are the corresponding HBMs.

<class name="MainCandidate" table="mainCandidates" dynamic-update="true" >
<id name="Id" column="TheName" type="string" unsaved-value="null">
<generator class="assigned"/>
</id>

<bag name="Steps" lazy="true" cascade="all-delete-orphan" order-by="stepOrder" inverse="true" >
<key column="TheName" />
<one-to-many class="Step" />
</bag>
</Class>

<class name="Step" table="tbl_step_key">
<many-to-one column="TheName" name="Rule" class="MainCandidate" cascade="none" />
</Class>

Whenever MainCandidate object is loaded, 'Step' table will be loaded lazily. 'TheName' is happened to be the primary key on 'MainCandidate' table and foreignkey on 'Step' table.

Due to our recent data migration to 'MainCandidate' table, some of 'TheName' column values are updated with trailing spaces and it went unnoticed. Recently we found out that the NHibernate query which is reponsible for loading the child 'Step' table is messed up because of that trailing spaces. We've traced that query through SQL Profiler.

My question is, is there anyway that we correct this problem without touching either of the above mentioned tables? How can we make the NHibernate query ignore the whitespaces?

Thanks inadvance.

Fabio Maulo

unread,
Aug 13, 2011, 4:45:28 PM8/13/11
to nhu...@googlegroups.com
Using the right type instead string.
Reply all
Reply to author
Forward
0 new messages