| Author |
Externalizing SQL statements in JEE
|
Hanna Habashy
Ranch Hand
Joined: Aug 20, 2003
Posts: 532
|
|
Hello all: We are using Hibernate as an ORM to build a JEE application. I want to know if putting the HQL in an external file is a good idea. If it is, why? and how it can be implemented? Thanks
|
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
|
 |
Jan Cumps
Bartender
Joined: Dec 20, 2006
Posts: 2343
|
|
I don't do it. To my feeling, the queries belong to the code. So I want them as close to the code as possible. It makes things easier to understand. I do externalize internationalization-sensitive things, like messages. There are other opinions around. If you want to externalize your queries, you could use Property files or a ResourceBundle. Regards, Jan [ April 27, 2007: Message edited by: Jan Cumps ]
|
OCUP UML fundamental
ITIL foundation
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26168
|
|
Hanna, It's a matter of personal preference. I find it useful to put things that might change, like the schema name, in a property file. If the queries are highly static, it could make sense to put them in a property file. I tend to do more dynamic queries and like them closer to the code. Also, if I change the query, I usually need to change the code (prepared statement or resultset), so it's helpful to have them in the same place.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: Externalizing SQL statements in JEE
|
|
|