Execute SQL defined from XML

4 messages Options
Embed this post
Permalink
Khang Ha

Execute SQL defined from XML

Reply Threaded More More options
Print post
Permalink
Hi all,

Im developing Maven with Struts 2 Basic framework.
I want hibernate to execute SQL (select,insert,update,delete) which is defined from XML file (like Maven with Spring framework) not from code  

How can I do that? Please help me
Thanks all!
mraible

Re: Execute SQL defined from XML

Reply Threaded More More options
Print post
Permalink
Can you explain 1) why you want to do this and 2) what your XML looks like?

Matt

On Wed, Apr 15, 2009 at 8:14 PM, Kenny Ha <[hidden email]> wrote:

Hi all,

Im developing Maven with Struts 2 Basic framework.
I want hibernate to execute SQL (select,insert,update,delete) which is
defined from XML file (like Maven with Spring framework) not from code

How can I do that? Please help me
Thanks all!
--
View this message in context: http://www.nabble.com/Execute-SQL-defined-from-XML-tp23070294s2369p23070294.html
Sent from the AppFuse - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Khang Ha

Re: Execute SQL defined from XML

Reply Threaded More More options
Print post
Permalink
1) I want to change my SQL without hard-code. Use XML file will be convenient.
2) Example :

I identify a SQL Map XML files to be loaded by this SQL map in sql-map-config.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<sqlMapConfig>
<sqlMap resource="Dept.xml" />
</sqlMapConfig>

This is file Dept.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<sqlMap>
<resultMap id="dept" class="com.Model.Dept" >
<result property="deptno"/>
<result property="dname"/>
<result property="loc"/>
</resultMap>
<select id="selectDept" parameterClass="com.Bean.Dept" resultMap="dept">
select deptno,
dname,
loc
from dept
</select>
<insert id="insertDept" parameterClass="com.Bean.Dept">
insert into dept(deptno, dname, loc)
values(#deptno#, #dname#, #loc#)
</insert>
</sqlMap>

Im using Maven with Struts 2 Basic framework. How to cofigure hibernate plugin to execute SQL from Dept.xml??

mraible wrote:
Can you explain 1) why you want to do this and 2) what your XML looks like?

Matt

On Wed, Apr 15, 2009 at 8:14 PM, Kenny Ha <vifaxocker@yahoo.com> wrote:

>
> Hi all,
>
> Im developing Maven with Struts 2 Basic framework.
> I want hibernate to execute SQL (select,insert,update,delete) which is
> defined from XML file (like Maven with Spring framework) not from code
>
> How can I do that? Please help me
> Thanks all!
> --
> View this message in context:
> http://www.nabble.com/Execute-SQL-defined-from-XML-tp23070294s2369p23070294.html
> Sent from the AppFuse - Dev mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@appfuse.dev.java.net
> For additional commands, e-mail: dev-help@appfuse.dev.java.net
>
>
mraible

Re: Execute SQL defined from XML

Reply Threaded More More options
Print post
Permalink
Why don't you just change to using iBATIS? If that doesn't work, you could take a look at the maven-sql-plugin or dbunit-maven-plugin.

Matt

On Wed, Apr 15, 2009 at 9:42 PM, Kenny Ha <[hidden email]> wrote:

1) I want to change my SQL without hard-code. Use XML file will be
convenient.
2) Example :

I identify a SQL Map XML files to be loaded by this SQL map in
sql-map-config.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<sqlMapConfig>
<sqlMap resource="Dept.xml" />
</sqlMapConfig>

This is file Dept.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<sqlMap>
<resultMap id="dept" class="com.Model.Dept" >
<result property="deptno"/>
<result property="dname"/>
<result property="loc"/>
</resultMap>
<select id="selectDept" parameterClass="com.Bean.Dept" resultMap="dept">
select deptno,
dname,
loc
from dept
</select>
<insert id="insertDept" parameterClass="com.Bean.Dept">
insert into dept(deptno, dname, loc)
values(#deptno#, #dname#, #loc#)
</insert>
</sqlMap>

Im using Maven with Struts 2 Basic framework. How to cofigure hibernate
plugin to execute SQL from Dept.xml??


mraible wrote:
>
> Can you explain 1) why you want to do this and 2) what your XML looks
> like?
>
> Matt
>
> On Wed, Apr 15, 2009 at 8:14 PM, Kenny Ha <[hidden email]> wrote:
>
>>
>> Hi all,
>>
>> Im developing Maven with Struts 2 Basic framework.
>> I want hibernate to execute SQL (select,insert,update,delete) which is
>> defined from XML file (like Maven with Spring framework) not from code
>>
>> How can I do that? Please help me
>> Thanks all!
>> --
>> View this message in context:
>> http://www.nabble.com/Execute-SQL-defined-from-XML-tp23070294s2369p23070294.html
>> Sent from the AppFuse - Dev mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Execute-SQL-defined-from-XML-tp23070294s2369p23070926.html
Sent from the AppFuse - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]