tree.hbm.xml
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<!
DOCTYPE
hibernate-mapping
PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
>
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<
hibernate-mapping
>
<
class
name
=
"ds_soft.ltxsys.auto.ltxemp.LtxProTreeEmpFound"
table
=
"tree_table"
schema
=
"dbo"
catalog
=
"dsltxsalary"
>
<
id
name
=
"id"
type
=
"string"
>
<
column
name
=
"id"
length
=
"32"
/>
<
generator
class
=
"assigned"
></
generator
>
</
id
>
<
property
name
=
"name"
type
=
"string"
>
<
column
name
=
"name"
length
=
"50"
/>
</
property
>
<
property
name
=
"cc"
type
=
"integer"
>
<
column
name
=
"cc"
not-null
=
"true"
/>
</
property
>
<
property
name
=
"childn"
type
=
"integer"
>
<
column
name
=
"childn"
not-null
=
"true"
/>
</
property
>
<
property
name
=
"pid"
type
=
"string"
>
<
column
name
=
"pid"
length
=
"32"
/>
</
property
>
<
property
name
=
"sort"
type
=
"string"
>
<
column
name
=
"sort"
length
=
"32"
/>
</
property
>
<
property
name
=
"imageurl"
type
=
"string"
>
<
column
name
=
"imageurl"
length
=
"200"
/>
</
property
>
</
class
>
<!--
调用存储过程就在这里配了
-->
<
sql-query
name
=
"getTreeEmpFound"
callable
=
"true"
>
<
return
alias
=
"emptree"
class
=
"ds_soft.ltxsys.auto.ltxemp.LtxProTreeEmpFound"
>
<
return-property
name
=
"id"
column
=
"id"
/>
<
return-property
name
=
"name"
column
=
"name"
/>
<
return-property
name
=
"cc"
column
=
"cc"
/>
<
return-property
name
=
"childn"
column
=
"childn"
/>
<
return-property
name
=
"pid"
column
=
"pid"
/>
<
return-property
name
=
"sort"
column
=
"sort"
></
return-property
>
<
return-property
name
=
"imageurl"
column
=
"imageurl"
></
return-property
>
</
return
>
<!--
这里就是存储过程名
-->
{call ltx_pro_tree_create(?)}
</
sql-query
>
</
hibernate-mapping
>
执行存储过程的通用方法
public
List findByNamedQuery(String querystr, Object[] parameters) {
Session session =
this
.getSession();
Query query =
null
;
List list =
null
;
try
{
query = session.getNamedQuery(querystr);
if
( parameters.
length
< 1)
list = query.list();
else
{
for
(
int
i=0; i < (parameters.
length
);i++){
query.setParameter(i , parameters[i]);
}
list = query.list();
}
}
catch
(Exception e)
{
System.
out
.println(
"
执行存储过程:
"
+ querystr +
"
参数:
"
);
System.
out
.println(parameters);
System.
out
.println(
"
失败
"
);
e.printStackTrace();
}
finally
{
SessionFactoryUtils.closeSessionIfNecessary(session,
this
.getSessionFactory());
return
list;
}
}
调用通用方法:
list =
this
.
comService
.findByNamedQuery(querystr, parameters);