Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writting query in xml

 
Varadhan Sesharaman
Ranch Hand
Posts: 30
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I want to know what is the main advantages of writing the sql query in xml format and then parsing to the sql format.

I need its main advantage and the comparison of it with the normal method of writing it in java file.


Thanks
Varadhan.s
 
Campbell Ritchie
Sheriff
Pie
Posts: 50241
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our XML forum.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keeping SQL out of code helps code maintainability. You can change SQL statements for only optimization needs in future still not re-building the code again.

Read - Keep SQL out of code
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varadhan Sesharaman wrote:

I want to know what is the main advantages of writing the sql query in xml format and then parsing to the sql format.


Do you have a reference where that's mentioned?
 
William P O'Sullivan
Ranch Hand
Posts: 859
Chrome IBM DB2 Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you can avoid this c**p:


That is a segment from a 114 line SQL statement, JOINing across 9 tables!

Whenever a developer has to change this, he or she must test (externally), the recompile the Class, rebuild the war, and redeploy.

Besides the minimal performance hit, storing SQL in XML will give you (if you do it right), tools like myBatis can really help.


WP
 
Palak Mathur
Ranch Hand
Posts: 342
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varadhan Sesharaman wrote:Hi guys,

I want to know what is the main advantages of writing the sql query in xml format and then parsing to the sql format.

I need its main advantage and the comparison of it with the normal method of writing it in java file.


Thanks
Varadhan.s


What do you mean by writing sql query in xml format? Do you mean to use XML to transfer data to and from database? Or do you mean that putting sql query as part of XML?
 
Varadhan Sesharaman
Ranch Hand
Posts: 30
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Palak Mathur,

In some cases i saw the query files are kept out of the java code .

The query are written in xml using the proper xml tags and the in run time the queries are converted into a normal query and then executed in java.

I am asking is there any specific reason for keeping the query out of the java file.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am asking is there any specific reason for keeping the query out of the java file.


1. Ease of changing the query without having to recompile
2. Facilitates record keeping, you can document the query using XSLT to create a nicely formatted record.
3. Reduced chance of introducing errors into Java file
4. Facilitate use by non-java-programmers
5. Probably, better security but I'm not sure about that

Bill
 
Varadhan Sesharaman
Ranch Hand
Posts: 30
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys for those answers.

Now i had some idea on this concept.


Thanks,
Varadhan.s
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic