From: <leg...@at...> - 2003-09-19 19:40:52
|
The following issue has been updated: Updater: Christopher D Riccio (mailto:cr...@cl...) Date: Fri, 19 Sep 2003 7:17 AM Comment: Please note: This code was built in an Eclipse test env using the db2 sample db Changes: Attachment changed to cdrHibernate.zip --------------------------------------------------------------------- For a full history of the issue, see: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-348&page=history --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-348 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-348 Summary: Pulling Named Native Sql Queries from an xml file Type: New Feature Status: Unassigned Priority: Minor Project: Hibernate2 Assignee: Reporter: Christopher D Riccio Created: Fri, 19 Sep 2003 7:09 AM Updated: Fri, 19 Sep 2003 7:17 AM Environment: Currently using Hibernate 2.1 B3 Description: This is my first time doing something like this so please bare with me. I will attach my code after creation of this issue. I built 2 classes that handle the pulling of named sql queries. I modeled the namedQueries.xml file after the example on the Hibernate Road Map. I tried to model my code after what was in the Configuration class that was written by Gavin. I also put in all the same versions of configure() that are in Configuration. Currently I have not actually integrated the code into my version of Hibernate. I noticed that Hibernate's JCASessionImpl class has a getNamedQuery( String ). I'm not sure if this was created for the purpose, but I tried to follow along to what that is then put a "queryManager" Map in where I had my SessionFactory after creation. To load the query I would just do something like this... NamedQuery nQuery = getNamedQuery( queryName ); Query query = session.createSQLQuery( nQuery.getQuery(), nQuery.getAliases(), nQuery.getClasses() ); There are 2 classes, NamedQuery which after looking at will be pretty self explanatory and NamedQueryConfiguration. When I was looking for code to model after in Hibernate, Configuration was the first thing to come to mind since it also loaded an xml file, so I tried to use all the same naming conventions, and even comments, as it did. Biggest difference, NamedQueryConfiguration returns a Map. The Map contains key - value pairs of queryName - NamedQuery. This way, after the NamedQueryConfiguration.configure() is called, then the map can just be set in the JCASessionImpl. Then call getNamedQuery and let it do the small code snippet above. I hope this all makes sense and isn't overkill on the information. Please let me know if there is any code or that needs to be changed based on naming, exception handling and any other coding standards. Thanx, Christopher D Riccio --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |