Thanks, that makes sense.

What is the session-factory configuration property to turn off the
validation? Is it done in the c# code or in the hibernate config file?

On Mon, Mar 23, 2009 at 9:21 AM, Fabio Maulo <[email protected]> wrote:

> <query name="IRI.GetAccounts"> Mean HQL<sql-query name="IRI.GetAccounts"> Mean
> SQL
>
> The validation at startup is only an option, you can turnoff it trough
> session-factory configuration properties.
>
> 2009/3/23 Eric <[email protected]>
>
>
>> I know this is not HQL, it is straight SQL. In our code, the string
>> query is read in from .hbm.xml mapping file, via
>>           IQuery query = this.Session.GetNamedQuery
>> ("IRI.GetAccounts");
>>
>>  and then the text of the named query is fed into a SQL Command:
>> SqlCommand command.CommandText = query.QueryString.Replace
>> (":accountType", "'" + accountType + "'");
>>
>> In NHibernate 2.0, I assume the queries are now validated
>> automatically and that is why they are failing during initialization
>> time because they must be HQL?. I can't seem to find any documentation
>> on how to disable validation of the named queries.
>>
>> Thanks
>>
>> On Mar 21, 9:05 am, Fabio Maulo <[email protected]> wrote:
>> >   union allis not HQL
>> >
>> > 2009/3/21 Fabio Maulo <[email protected]>
>> >
>> >
>> >
>> > > Activate the log WARN and take a look therefor example
>> > >  (select Id from IRINames where Type = :accountType)
>> > > this part is not HQL.
>> >
>> > > 2009/3/20 Eric <[email protected]>
>> >
>> > >> Hi-
>> > >> We are investigating upgrading from NH 1.2 to 2.0. After fixing all
>> of
>> > >> the namespace changes, I am getting an error with the named queries.
>> > >> In 1.2 they worked fine, now I get a runtime error with the following
>> > >> message:
>> >
>> > >> Errors in named queries: {IRI.GetAccounts}.... for all of the named
>> > >> queries. Below is the first named query:
>> > >> <query name="IRI.GetAccounts">
>> >
>> > >>                select r.RetailerId as Id, r.Name, b.BannerId, b.Name
>> as
>> > >> BannerName,
>> > >> map.AccountId, 'Banner' as 'Type', names.IsMviActive as IsMviActive
>> > >>                from IRIMapping map
>> > >>                join IRINames names
>> > >>                on names.Id = map.AccountId
>> > >>                join Retailer r
>> > >>                on r.RetailerId = map.RetailerId
>> > >>                join Banner b
>> > >>                on b.BannerId = map.BannerId
>> > >>                where map.RetailerId is not null and map.BannerId is
>> not
>> > >> null
>> > >>                and map.AccountId in (select Id from IRINames where
>> Type
>> > >> = :accountType)
>> > >>                union all
>> > >>                select r.RetailerId as Id, r.Name, '0' as BannerId,
>> '0' as
>> > >> BannerName, map.AccountId, 'Retailer' as 'Type', names.IsMviActive as
>> > >> IsMviActive
>> > >>                from IRIMapping map
>> > >>                join IRINames names
>> > >>                on names.Id = map.AccountId
>> > >>                join Retailer r
>> > >>                on r.RetailerId = map.RetailerId
>> > >>                where map.RetailerId is not null and map.BannerId is
>> null
>> > >>                and map.AccountId in (select Id from IRINames where
>> Type
>> > >> = :accountType)
>> > >>                union all
>> > >>                select f.FormatId as Id, f.Name, '0' as BannerId, '0'
>> as
>> > >> BannerName,
>> > >> map.AccountId, 'Format' as 'Type', names.IsMviActive as IsMviActive
>> > >>                from IRIMapping map
>> > >>                join IRINames names
>> > >>                on names.Id = map.AccountId
>> > >>                join Format f
>> > >>                on f.FormatId = map.FormatId
>> > >>                where map.AccountId in (select Id from IRINames where
>> Type
>> > >> = :accountType)
>> > >>                union all
>> > >>                select ch.ChannelId as Id, ch.Name, '0' as BannerId,
>> '0' as
>> > >> BannerName, map.AccountId, 'Channel' as 'Type', names.IsMviActive as
>> > >> IsMviActive
>> > >>                from IRIMapping map
>> > >>                join IRINames names
>> > >>                on names.Id = map.AccountId
>> > >>                join Channel ch
>> > >>                on ch.ChannelId = map.ChannelId
>> > >>                where map.AccountId in (select Id from IRINames where
>> Type
>> > >> = :accountType)
>> > >>                order by Name, BannerName
>> >
>> > >>        </query>
>> >
>> > >> This query runs fine in SQL 2005 Management stuido. the :accountType
>> > >> variables are actually done through a string replacement before
>> > >> running they query.
>> >
>> > >> Some of the queries, however do not have any variables at all, and
>> > >> those are still listed in the error.
>> >
>> > >> what changed between 1.2 and 2.0 that would cause the named queries
>> to
>> > >> not work? I can't seem to find any documentation on it.
>> >
>> > >> Thanks
>> >
>> > >> Eric
>> >
>> > > --
>> > > Fabio Maulo
>> >
>> > --
>> > Fabio Maulo
>>
>>
>
>
> --
> Fabio Maulo
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to