These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: SQL Outer Join
PostPosted: Tue Sep 28, 2010 4:17 pm 
Regular
Regular

Joined: Sat Apr 23, 2005 7:28 am
Posts: 52
I'm trying to reproduce the results of a single SQL call in Hibernate - but so far no luck.
The SQL query is:
Code:

SELECT BN.*, OP.*, MA.*, DOC.*
FROM BOM_NODE BN
LEFT OUTER JOIN MATERIAL MA ON BN.DOCUMENT_ID = MA.ID AND BN.DOCUMENT_TYPE = 'M'
LEFT OUTER JOIN OPERATION OP ON BN.DOCUMENT_ID = OP.ID AND BN.DOCUMENT_TYPE = 'O'   
LEFT OUTER JOIN DOCUMENT DOC ON BN.DOCUMENT_ID = DOC.ID AND BN.DOCUMENT_TYPE = 'D' 
WHERE BN.DOCUMENT_TYPE IN ('M', 'O', 'D')

If I use createSQLQuery(String query) to retrieve a list of bojects from the database, Hibernate only returns null values from the Operation and Document tables whereas running the query directly against SQL Server 2008 I get all the expected results.

If I define many-to-one properties in the BOM_NODE mapping doucment, Hibernate executes a query for each table (unsatisfactory).

I'd welcome any advice towards soultion that allows me to retrieve the entire graph of data via Hibernate with a single query.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.