the UserAudit looks like this:

public class UserAudit
{
        readonly DateTime createdOn = DateTime.Now;
        string page;
        User user;

        public virtual string Page { get { return page; } set { page =
value; } }
        public virtual DateTime CreatedOn { get { return createdOn; } }
        public virtual User User { get { return user; } set { user =
value; } }
}

I tried also

insert into UserAudit (Page, User) select :page, u.Id from User u
where u.Id = :userId
and
insert into UserAudit (Page, User.Id) select :page, u.Id from User u
where u.Id = :userId

but I get the same exception.

On Oct 6, 3:01 pm, Fabio Maulo <[email protected]> wrote:
>  [User] <= that is a MsSQL column name
> with HQL you have to use properties names
>
>
>
>
>
>
>
>
>
> On Tue, Oct 5, 2010 at 1:31 PM, bdaniel7 <[email protected]> wrote:
> > Hello,
>
> > I'm trying to perform an update using HQL:
>
> > string query = @"insert into UserAudit (Page, [User]) select :page,
> > u.Id from User u where u.Id = :userId";
>
> >  sqlQuery = session.CreateQuery( query )
> >                .SetParameter( "page", requestedPage )
> >                .SetParameter( "userId", UserId );
> >  sqlQuery.ExecuteUpdate();
>
> > and I get this exception:
>
> > NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type
> > 'Antlr.Runtime.NoViableAltException' was thrown. near line 1, column
> > 29 [insert into UserAudit (Page, [User]) select :page, u.Id from User
> > u where u.Id = :userId]
>
> > column 29 would be at i from insert.
>
> > The same query
> > "insert into UserAudit (Page, [User]) select 'boo', u.Id from Users u
> > where u.Id = 1"
> > works when executed in SQL Mgmt Studio.
>
> > I tested with a string instead of param :page, but I get the same
> > exception.
>
> > I'm running Antlr 3.1.0 and NH 2.1.2
>
> > What it's wrong with it?
>
> > Thanks,
> > Daniel
>
> > --
> > 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]<nhusers%[email protected] 
> > >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> 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