Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1374 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  NHibernate SQL natif

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

NHibernate SQL natif

n°1357627
cantonaifo​u
nage vers la surface
Posté le 02-05-2006 à 11:08:08  profilanswer
 

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

mood
Publicité
Posté le 02-05-2006 à 11:08:08  profilanswer
 

n°1357702
Smanux
Posté le 02-05-2006 à 12:19:57  profilanswer
 

NHibernate ce serait plutot pour le forum .NET :)


---------------
Commons Configuration - http://jakarta.apache.org/commons/configuration
n°1357705
the real m​oins moins
Posté le 02-05-2006 à 12:21:55  profilanswer
 

et fais plutot des prepared statements :|


---------------
Hey toi, tu veux acheter des minifigurines Lego, non ?
n°1357727
cantonaifo​u
nage vers la surface
Posté le 02-05-2006 à 13:08:44  profilanswer
 

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.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  NHibernate SQL natif

 

Sujets relatifs
convertir macro excel en requete SQLRequête SQL avec VB
pblm de requete SQL besoin aide !!!Class PHP5 de gestion de requetes SQL simples
convertir base de donnée excel en base de donnée SQL[VB.NET CF2.0] Sql server CE
[MFC et ODBC] Requete SQLProbleme SQL trop lent
SQL Server -> Peut on avoir un champ Dynamique dans une clause WHERE ?Windev export fichier SQL ???
Plus de sujets relatifs à : NHibernate SQL natif


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR