Using NHibernate 3, I have a Linq query

Line 12:         public long CountActive()
Line 13:         {
Line 14:             return EntityCollection   // Entity Collection is
a wrapper for ISession.Query<Category>()
Line 15:                     .Count(c => c.Ornaments.Count > 0);
Line 16:         }

It is generating the following MySQL query:

select cast(count(* ) as INTEGER) as col_0_0_
from   Categories category0_
where  (select cast(count(* ) as INTEGER)
        from   CategoryOrnaments ornaments1_,
               Ornaments ornament2_
        where  category0_.CategoryId = ornaments1_.CategoryId
               and ornaments1_.OrnamentId = ornament2_.OrnamentId) >0

If I remove the cast statements, this query will run fine in mysql.  I
have tried the same functionality on SqlServer and it works fine.

My NH config is as follows...

    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
        <session-factory>
            <property
name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle</property>
            <property
name="connection.provider">NHibernate.Connection.DriverConnectionProvider</
property>

            <!--<property
name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
            <property
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
property>
            <property name="connection.connection_string">..Removed
for user group post..</property>-->

            <property name="dialect">NHibernate.Dialect.MySQLDialect</
property>
            <property
name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</
property>
            <property name="connection.connection_string">...Removed
for user group post...</property>

            <property name="current_session_context_class">web</
property>
            <property name="show_sql">false</property>
        </session-factory>
    </hibernate-configuration>

Am I configuring the Mysql Dialect wrong?  Or is this a known issue?

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