在我的项目早期,我使用了Hibernate 3.3.2,openJPA 2.1.1的组合来连接数据库并从表中检索信息.现在我想删除Hibernate并使用openJPA进行连接并检索信息.
我之前的persistence.xml配置是
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd">
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.connection.url" value="jdbc:mysql://10.10.10.10:3306/test?autoReconnect=true"/>
<property name="hibernate.connection.username" value="user"/>
<property name="hibernate.connection.password" value="pwd"/>
<property name="hibernate.generate_statistics" value="true"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.OSCacheProvider"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="1800"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="1800"/>
<property name="c3p0.idleConnectionTestPeriod" value="1810"/>
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
现在我想转到openJPA 2.1.1,为此我的persistence.xml文件是
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" …Run Code Online (Sandbox Code Playgroud) 我是使用jqgrid的新手.
在新页面加载时,网格正在从数据库中正确加载数据.之后由于loadonce:true,网格没有从数据库重新加载数据以进行添加/编辑/删除.
我的应用程序组合是JSP,Servlet,MySQL
我有一个具有以下设置的网格
jQuery("#userList").jqGrid({
url: '<%=request.getContextPath()%>/userJqGrid?q=1&action=fetchData&userCookie=<%= encodedCookie%>',
datatype: 'xml',
mtype: 'GET',
colNames:['<%= userProp.getProperty(userColNames[0])%>',
'<%= userProp.getProperty(userColNames[1])%>',
'<%= userProp.getProperty(userColNames[2])%>',
'<%= userProp.getProperty(userColNames[3])%>',
'<%= userProp.getProperty(userColNames[4])%>',
'<%= userProp.getProperty(userColNames[5])%>'
],
colModel:[
{name:'<%= userColNames[0]%>',index:'<%= userColNames[0]%>',
width:120,sortable:true,editable:true,editrules:{required:true},formoptions:{rowpos:1, elmprefix:'*'}},
{name:'<%= userColNames[1]%>',index:'<%= userColNames[1]%>',
width:130,sortable:true,editable:true},
{name:'<%= userColNames[2]%>',index:'<%= userColNames[2]%>',
width:100,sortable:true,editable:true,editrules:{required:true},formoptions:{rowpos:3, elmprefix:'*'}},
{name:'<%= userColNames[3]%>',index:'<%= userColNames[3]%>',
width:180,sortable:true,editable:true,editrules:{email:true,required:true},formoptions:{rowpos:4, elmprefix:'*'}},
{name:'<%= userColNames[4]%>',index:'<%= userColNames[4]%>',
width:100,sortable:true,editable:true},
{name:'<%= userColNames[5]%>',index:'<%= userColNames[5]%>',
width:100,sortable:true,editable:true},
],
pager: '#pager1',
rowNum:50,
height:'auto',
//rowList:[10,20,30],
loadonce: true,
sortname:'<%= userColNames[0]%>',
viewrecords: true,
editurl:'<%=request.getContextPath()%>/userJqGrid?q=1&action=addData&userCookie=<%= encodedCookie%>',
caption: 'User Grid',
ondblClickRow: function(rowid) {
$("#userList").jqGrid('editGridRow',rowid, userEditParam);
return;
}
});
$("#userList").jqGrid('navGrid',"#pager1",{add:true,edit:true,del:true});
$("#userList").jqGrid('gridResize', …Run Code Online (Sandbox Code Playgroud)