NHibernate SQL natif

NHibernate SQL natif - Java - Programmation

Marsh Posté le 02-05-2006 à 11:08:08    

Bonjour,  
 
J'ai besoin de faire une requete SQL native pour des raisons de temps de réponsse (Nhibernate me fait des requetes qui donne 2 millions d'opération)  
Mais voila, ma requete SQL native ne passe pas et me renvoie cette exception:
 
ERROR NHibernate.ADOException error in FindBySQL  
System.IndexOutOfRangeException: Id0_  
 
Voici le code de mon appli
 

Code :
  1. //query nhibernate
  2.   int release;
  3.   release = (int) a_type;
  4.   string sql_str = "SELECT distinct QIdxConstituent.* FROM dbo.QIdxConstituent QIdxConstituent ";
  5.   sql_str += "INNER JOIN dbo.QIdxComposition qidxcomposition ON QIdxConstituent.CompositionId = qidxcomposition.Id , dbo.QIdxIndex qIdxIndex ";
  6.   sql_str += "WHERE (qidxcomposition.ReleaseDate ='" + a_date.Month +"/"+ a_date.Day +"/"+ a_date.Year + "') or ( (qidxcomposition.ReleaseDate ='" + a_date.Month +"/"+ a_date.Day +"/"+ a_date.Year + "') ";
  7.   sql_str += "AND (qidxcomposition.ReleaseType =" + release + " ) AND (qidxcomposition.IndexTicker ='" + a_indexIdentifier + "') ";
  8.   sql_str += "AND (qIdxIndex.Ticker = qidxcomposition.IndexTicker) AND (qIdxIndex.RIC = qidxcomposition.IndexTicker))";
  9.   IQuery l_query = a_hibernator.CreateSQLQuery( sql_str, "QIdxConstituent", typeof(QIdxConstituent));
  10.   IList l_hqlResult =  l_query.List();
  11.   return l_hqlResult;


 
La requete original =  
SELECT distinct qidxconstituent.Id AS Id, qidxconstituent.CompositionId AS CompositionId, qidxconstituent.InstrumentId AS InstrumentId, qidxconstituent.Weight AS Weight FROM dbo.QIdxConstituent qidxconstituent INNER JOIN dbo.QIdxComposition qidxcompos1_ ON qidxconstituent.CompositionId = qidxcompos1_.Id , dbo.QIdxIndex qidxindex2_ WHERE (qidxcompos1_.ReleaseDate ='1/3/2030') or ( (qidxcompos1_.ReleaseDate ='1/3/2030') AND (qidxcompos1_.ReleaseType =0) AND (qidxcompos1_.IndexTicker ='MMMM999999') AND (qidxindex2_.Ticker = qidxcompos1_.IndexTicker) AND (qidxindex2_.RIC = qidxcompos1_.IndexTicker))
 
Merci

Reply

Marsh Posté le 02-05-2006 à 11:08:08   

Reply

Marsh Posté le 02-05-2006 à 12:19:57    

NHibernate ce serait plutot pour le forum .NET :)


---------------
Commons Configuration - http://jakarta.apache.org/commons/configuration
Reply

Marsh Posté le 02-05-2006 à 12:21:55    

et fais plutot des prepared statements :|


---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?
Reply

Marsh Posté le 02-05-2006 à 13:08:44    

En fait, même avec une requete simple ca plante... :  
 
string sql_str = "SELECT {QIdxConstituent.*} FROM dbo.QIdxConstituent {QIdxConstituent} ";
sql_str += "WHERE {QIdxConstituent.Id} = 1 ";
 
L'erreur est la même.

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed