<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" default-autowire="byName" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd "> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/hch/hcdoc/model/persist/entity/FormInfo.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/FormTableIndexInfo.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/CodeClassHc.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/FormTableFieldInfo.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/CodeClassDoc.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/FormTableInfo.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/UserInfo.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/CodeDoc.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/UnitFrame.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/entity/TreeMain.hbm.xml</value>
<value>com/hch/hcdoc/model/persist/auto/table1/table1.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">25</prop>
<prop key="hibernate.c3p0.minPoolSize">5</prop>
<prop key="hibernate.c3p0.maxPoolSize">20</prop>
<prop key="hibernate.c3p0.timeout">60</prop>
<prop key="hibernate.c3p0.max_statement">50</prop>
<prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
<!--
<prop key="hibernate.cache.use_query_cache">true</prop>
-->
<prop key="hibernate.cache.parovider_class">org.hibernate.cache.OSCacheProvider</prop>
</props>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value=" jdbc:oracle:thin:@192.168.66.234:1521:oracl" />
<property name="username" value="hcdoc" />
<property name="password" value="111111" />
</bean>
用jdom在<property name="mappingResources">
<list>
<value>com/hch/hcdoc/model/persist/entity/FormInfo.hbm.xml</value>
这里插入hibenrate的映射文件<value>com/hch/hcdoc/model/persist/entity/*****.hbm.xml</value>
,怎么搞????注明二级的bean有多个,名字均一样,怎么找到第一个的list所在节点,然后往其下写入hbm.xml文件?
解决方案 »
- 帮帮看看哪里数组索引越界了
- 一个很有趣的hibernate问题,大家一起分享
- 如何建立Praparedstatement批处理对象?
- Hibernate自动生成持久化类
- Base64Binary数据类型的读取
- 各位大歌..再次求救...struts连数据库老是不举.有哪位测试成功的可否共享一下思路与代码.
- 最简单的正则"^abc"我匹配不出来,为什么啊
- 关于在JBUILDER7下开发EJB的问题?
- Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'
- 数据在jsp页面展示问题,可以有哪些方法,或在项目实际开发中一般是怎么处理的
- C# 转为 java 代码
- JSP+MYSQL分页怎么写
public static void addHbm(String tableName) throws JDOMException, FileNotFoundException,
IOException {
System.out.println("--add");
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build("src/etc/applicationContext.xml");
Element root = doc.getRootElement();
Element rooElement = root.getChild("list");
Element element = new Element("value");
element.addContent("com/hch/hcdoc/model/persist/auto/table1/"+tableName+".hbm.xml");//将kingwong作为content添加到name元素
root.addContent(element);//将name元素作为content添加到根元素 XMLOutputter out = new XMLOutputter();
out.output(doc, new FileOutputStream("src/etc/applicationContext.xml"));
}这样只能加入到根节点,如何插入到指定的list下面相应的位子·还请大家帮我看看···
Element root = doc.getRootElement();//获得根节点
List<Element> list = root.getChildren();
for(Element e:list) {
//获取ID值
if(e.getAttributeValue("id").equals("sessionFactory")) { ///
List<Element> list1 = e.getChildren();
for (Element element : list1) {
System.out.println(element.getAttributeValue("name"));
if(element.getAttributeValue("name").equals("mappingResources")) { ///
List<Element> list2 = element.getChildren();
Element element2 = element.getChild("list");
Element element10 = new Element("value");
element10.setText("ssss");
element2.addContent(element10);
doc.setContent(element2);
} }
}
}
}
还是无解····················
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import org.jdom.xpath.XPath;
public class test { public static void main(String[] args) throws JDOMException, IOException {
SAXBuilder sax=new SAXBuilder();
Document doc= sax.build(Thread.currentThread().getContextClassLoader().getResourceAsStream("applicationContent.xml"));
Element rootEl=doc.getRootElement();
Element l=(Element) XPath.selectSingleNode(rootEl, "//beans/bean/property/list");
System.out.println(l);
Element value=new Element("value");
value.addContent("abc");
l.addContent(value);
XMLOutputter out=new XMLOutputter();
out.output(doc, new FileOutputStream(new File("a.xml")));
}
}
public static void addXml() throws JDOMException, FileNotFoundException,
IOException {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build("src/xml/applicationContext.xml");// 获得文档对象
Element root = doc.getRootElement();// 获得根节点 List<Element> list = root.getChildren();
Namespace namespace1 = Namespace
.getNamespace("http://www.springframework.org/schema/beans");
for (Element element : list) {
if ("sessionFactory".equals(element.getAttributeValue("id"))) {
List<Element> list1 = element.getChildren();
for (Element element2 : list1) {
if ("mappingResources".equals(element2
.getAttributeValue("name"))) { List<Element> list2 = element2.getChildren();
for (Element element3 : list2) {
Element element4 = new Element("value");
element4.addContent("aaaaaaaaaaaa.hbm.xml");
element4.setNamespace(namespace1);
element3.addContent(element4);
}
}
}
}
} // 文件处理
XMLOutputter out = new XMLOutputter();
out.output(doc, new FileOutputStream("src/xml/applicationContext.xml")); }大功告成~~~哈哈······
用xpath就解决了