-->
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.  [ 2 posts ] 
Author Message
 Post subject: Using an existing datasource
PostPosted: Thu Feb 16, 2006 9:24 am 
Newbie

Joined: Wed Feb 08, 2006 6:17 am
Posts: 9
Hi All,
currently I'm writing an app using Hibernate 3 against an existing Oracle 10g database. I'm new to Hibernate and databases in general having spent most of my time writing Swing apps and so I'm wondering how I would model this SQL query. Am I going along the right lines of creating a POJO for each table in the query? How would I then map these in the hbm.xml file so that I can execute this query? What would the best way of executing this query be? SQL, HQL or using the Critera interface?

Here's the SQL.

stSql = "SELECT Act.ID AS SwitchBoardID, ActRelationship.sequenceNumber, ActRelationship.OutboundActID, Concept.Concept AS ItemText"
stSql = stSql & " FROM Role LEFT JOIN (((Act LEFT JOIN ActRelationship ON Act.ID = ActRelationship.InboundActID)"
stSql = stSql & " LEFT JOIN Concept ON Act.Code = Concept.ConceptCode)"
stSql = stSql & " RIGHT JOIN Participation ON Act.ID = Participation.ActID) ON Role.ID = Participation.RoleID"
stSql = stSql & " WHERE (((Role.ScoperEntityID)=" & OrgContext & ")"
stSql = stSql & " AND ((Role.PlayerEntityID)=" & UserEntityID & ")"
stSql = stSql & " AND ((ActRelationship.OutboundActID)=" & BtnOption & "));"

Thanks in advance

Angus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 11:07 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
well, your post asks about pretty much everything, so first I shall point you to the book at the top of this page :)

for a good place to start, I'd recommend reading up on mapping tables ( http://www.hibernate.org/hib_docs/v3/re ... pping.html ) and start writing your hbm.xml files.

Yes, writing a POJO for each table is a good practice. HQL is a good way to write queries because it is database independent (Criteria is better for dynamic queries, or projections)

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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

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.