views:

26

answers:

0

Im using NHibernate to execute a SQL statement that first inserts a new row, then inserts a row in a different table based on the id that the first insert generated.

The SQL for it works fine:

 INSERT INTO messages(MessageSubject,MessageText,MessageSenderTribeID,MessageSentTime,MessageHasAttachments) 
VALUES('subject', 'text',204948, 2009, 0);
SET @last=LAST_INSERT_ID();
INSERT INTO messagelinks(MessageID,MessageReceiverNodeID,SendMethodID)
VALUES(@last, 204948,3);
SELECT * FROM messages WHERE Messages.MessageID = @last;

However when i do this:

var session = NHibernateHelper.GetCurrentSession();
                IQuery query = session.CreateSQLQuery(that sql here).AddEntity(typeof(messages));



                IList<messages> messageRes = query.List<messages>();

It throws an error saying not all named parameters have been set?

I dont need any named parameters or anything - just need nhibernate to execute the sql. Please help, thanks :)