Hi everyone, I have implemented a IUserType for my custom data type (whose
SqlType id DbType.Object). Everything works great with inserts and selects,
the only problem is with named sql queries.
The problem is that my type gets serialized in the query (while debugging I
found that GuessType(typeof(MyClass)), in AbstractQueryImpl.cs, in the
SetParameter<T>(string name, T val) method returns
Nhibernate.Type.Serializable), and a GenericADOException is thrown, since an
attempt to insert a byte array into a different type colum is being made.
The named sql query is defined as follows:
<sql-query name="events_near">
<return alias="b" class="Data.Event, Data">
<return-property name="ownerid" column="ownerid" />
<return-property name="title" column="title" />
<return-property name="type" column="type" />
<return-property name="datebegins" column="datebegins" />
<return-property name="coordinates" column="coordinates" />
<return-property name="distance" column="distance" />
</return>
<query-param name="position" type="Point" />
<query-param name="distance" type="int" />
<![CDATA[
SELECT ownerid AS b.id,
placeid as b.placeid,
title as b.title,
type as b.type,
datebegins as b.datebegins,
coordinates as b.coordinates,
distance as b.distance
FROM events_near(:position, :distance)
]]>
</sql-query>
And the code that calls this named query is:
public IList<Event> GetEventsByDistance(Point position, int radius)
{
//return GetAllEvents();
return session.GetNamedQuery("events_near")
.SetParameter("position", position)
.SetParameter("distance", radius)
.List<Event>();
}
So, as you can see, the type in question is called "Point".
Does anyone know how to solve this?
Thanks in advance.
* Note: I have read
http://nhforge.org/wikis/howtonh/use-postgresql-arrays-with-nhibernate.aspxand
implemented a specialized driver in a analogous way. Though I don't
fully understand the process, I still haven't had success.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.