Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
I am using Hibernate 3.0 with SQL Server 2000 as back end.
I am using native SQL with join. The query is getting executed properly.
But when I try to retrieve the results using object[] , I am getting reference of the first table and a null reference of the second table.
I am furnishing the code below for ur reference.
public List findItemsToProcess(String status,String scheduledDate) throws EnfsApplicationException {
try {
String query = "select {I.*},{F.*} from dbo.ItemstoProcess I,FileReceivedSentLog F " +
"where I.FileRecievedSentId *= F.Id and " +
"((I.ScheduledDate >= ?) or (I.Status = ?)) and " +
"(I.ScheduledDate <= ?)" ;
Session session = getSession();
SQLQuery sqlQuery = session.createSQLQuery(query);
sqlQuery.addEntity("I",ItemsToProcess.class);
sqlQuery.addEntity("F",FileReceivedSentLog.class);
sqlQuery.setString(0,scheduledDate);
sqlQuery.setString(1,status);
sqlQuery.setString(2,scheduledDate);
return sqlQuery.list();
}
catch(HibernateException e) {
throw new EnfsApplicationException(e);
}
// ****** Test Case ********
List result = itemsToProcess.findItemsToProcess("P","1/1/2005");
Iterator i = result.iterator();
while(i.hasNext()) {
Object[]pair = (Object[])i.next();
System.out.println("Pair Length : " + pair.length);
System.out.println("Pair 0 : " + pair[0].toString());
System.out.println("Pair 0 : " + pair[1].toString());
}
First SOP return class name of ItemsToProcess
Second SOP doest not return class name of FileReceivedSentLog , Instead it returns null.
Matter is urgent. Pl help
Regards
Seshadri