这让我疯狂.与直接通过Navicat运行查询相比,使hibernate简单选择是如此之慢.更有趣的是什么.使用本地数据库运行此查询非常快,但远程使用它确实很差.
我正在做Hibernate本机SQL查询(因为HQL或Criteria不支持左连接):
List list = new ArrayList();
String queryStr = "select s.* from sales_unit s left join sales_unit_relation r on (s.sales_unit_id = r.sales_unit_child_id) where r.sales_unit_child_id is null";
Query query = session.createSQLQuery( queryStr ).addEntity( SalesUnit.class );
Long start = System.currentTimeMillis();
list.addAll( query.list() );
Long stop = System.currentTimeMillis();
System.out.println( "Time: " + (stop - start) + "ms." );
Run Code Online (Sandbox Code Playgroud)
实体的结构并不重要.SALES_UNIT和SALES_UNIT_RELATION表的记录大约为28k
结果在我当地的JBoss上用本地数据库运行,大约30-120ms.在远程数据库运行时,本地JBoss(相同的数据)导致时间在30000-40000ms之间.当我使用Navicat运行此查询时,本地和远程调用都非常快(20-30ms).
本地和远程数据库都以相同的方式安装 - > Oracle Enterprise Edition 11.2.0.1.0.
可能是这种糟糕表现的问题?我该怎么调试呢?
阅读:简单的hibernate查询返回非常缓慢,但设置构造函数没有改变任何东西
编辑.
SALES_UNIT表包含一些基本信息abot sales unit节点,例如name等.唯一的关联是表SALES_UNIT_TYPE,如ManyToOne.主键是ID和字段VALID_FROM_DTTM,即日期.
SALES_UNIT_RELATION包含销售单位节点之间的PARENT-CHILD关系.由SALES_UNIT_PARENT_ID,SALES_UNIT_CHILD_ID和VALID_TO_DTTM/VALID_FROM_DTTM组成.与任何表都没有关联.这里的PK是..PARENT_ID,.. …
我正在使用OSM渲染地图,我在为页面元素设置zIndex时遇到了一些严重的问题.
JS的一部分看起来像这样:
var userRoute = new OpenLayers.Layer.Vector( "KML", {
sphericalMercator : true,
styleMap: styleMap,
rendererOptions: { zIndexing: true }
} );
var markers = new OpenLayers.Layer.Markers( "Markers", {
sphericalMercator : true,
rendererOptions: { zIndexing: true }
} );
markers.setZIndex( 500 );
userRoute.setZIndex( 200 );
Run Code Online (Sandbox Code Playgroud)
现在在为我设置的第一个元素解析KML文件时
var startFlag = new OpenLayers.Icon( '/start_flag_2.png', new OpenLayers.Size( 23, 22 ) );
markers.addMarker( new OpenLayers.Marker( latlon, startFlag ) )
Run Code Online (Sandbox Code Playgroud)
最后一个元素也是如此.:
var stopFlag = new OpenLayers.Icon( '/stop_flag_2.png', new OpenLayers.Size( 23, 22 ) );
markers.addMarker( new OpenLayers.Marker( …
Run Code Online (Sandbox Code Playgroud) 我目前正在学习使用Spring MVC.在开发过程中,我使用Ajax和jQuery四种不同的表单处理方式.现在,我想知道每种方法的优点和缺点是什么.还有其他人吗?
假设我们有一个非常简单的形式,只有2个输入
<input id="name" type="text" value"Name">
<input id="active" type="checkbox">
<input type="button" onclick="submitForm()">
Run Code Online (Sandbox Code Playgroud)
假设我们没有验证客户端和服务器站点上的数据.我们还将omitt处理返回的数据.我只对将数据发送到服务器感兴趣.现在我们如何处理提交?我的解决方案是:
1.基于PathVariable的请求
JS发送请求看起来像这样:
function submitForm() {
var name = jQuery("#name").val();
var active = jQuery("#active").is("checked");
jQuery.ajax("/Submit/Name/" + name + "/Active/"+ active + "/",
{
type:"POST"
});
}
Run Code Online (Sandbox Code Playgroud)
还有控制器:
@RequestMapping(value="/Submit/Name/{name}/Active/{active}/",method=RequestMethod.POST)
publis void submitForm(@PathVariable String name, @PathVariable Boolean active)
{ //something not important here }
Run Code Online (Sandbox Code Playgroud)
在我看来,优点
缺点
/
在发送到服务器的数据中用作char的问题2.请求数据
我不知道如何命名它,但这是JS文件中的想法:
function submitForm() {
var name = jQuery("#name").val();
var active = jQuery("#active").is("checked");
var object …
Run Code Online (Sandbox Code Playgroud) 我正在使用jsTree(1.0-rc3)和AJAX加载数据的选项,我有一个加载约2000个子节点的问题.虽然服务器在几秒钟内响应,但只需要大约40秒的jsTree来在浏览器中呈现结果(chrome,FF).除此之外,FF从'jquery-1.7.2.min.js'返回没有响应的信息.相同数量的数据冻结了IE.它是否超载了数据?还是某种bug?是否有任何可变因素,可以帮助我更快地渲染?
jQuery( "#dependency-tree" ).jstree(
{
'plugins':['themes', 'json_data', 'ui', 'core', 'types', 'sort'],
"json_data":{
"progressive_render": true,
"data":initData,
cache:false,
"ajax":{
"url":function ( node )
{
return appContext + 'GetUnitsNode/'
+ node.attr( 'id' );
},
dataType:"text",
"success":function ( data )
{
if ( data == "none" )
{
return false;
}
return jQuery.parseJSON( data );
}
}
},
"ui":{
'select_limit':1
},
"core":{
'animation':0,
'html_titles':true
},
"themes":{
"theme":"rules",
"dots":true,
"icons":true
},
"types":{
"types":{
"default":{
"icon":{
"image":appContext + "/img/orange.png"
}
}
}
},
"sort":function ( a, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试访问嵌套数组元素,如下所示:
$dbSettings = $sm->get( 'Config' )[ 'doctrine' ][ 'connection' ][ 'orm_default' ][ 'params' ];
Run Code Online (Sandbox Code Playgroud)
它在Module.php
Zend的框架2项目中.$sm->get('Config')
返回一个数组,我可以使用PHP 5.4在本地上面的代码访问,同时在客户端的机器上这样做,它给我一个错误:
Parse error: syntax error, unexpected '[' in /home/.../azk/module/Main/Module.php on line 121
Run Code Online (Sandbox Code Playgroud)
PHP 5.3 <=> 5.4在访问嵌套数组方面有什么区别,或者我有一些默认的PHP配置在客户机上设置不同?
我坚持这个问题.数据库架构由其他人提供,所以我不能简单地更改名称.我尝试在任何地方添加适当的注释,也许我错过了一些东西(显而易见)?
这是我的完整映射(很多classess),我会省略getter/setter.
问题是当hibernate试图获得所有 List<ControlRuleAttrib> controlRuleAttribs
控制规则
@Entity
@Table(name = "CONTROL_RULE")
public class ControlRule implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CONTROL_RULE_ID")
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@Cascade(CascadeType.ALL)
@JoinColumn(name = "CONTROL_RULE_TYPE_ID")
@ForeignKey(name = "CONTROL_RULE_TYPE_ID")
private ControlRuleType controlRuleType;
@Column(name = "JOB_NM")
private String jobname;
@Column(name = "LIBRARY_NM")
private String libraryname;
@Column(name = "TABLE_NM")
private String tablename;
@Column(name = "COLUMN_NM")
private String columnname;
@OneToMany(fetch = FetchType.LAZY)
@Cascade(CascadeType.ALL)
@JoinTable(name = "CONTROL_RULE_ATTRIB", joinColumns = {
@JoinColumn(name = "CONTROL_RULE_ID", nullable = false, updatable …
Run Code Online (Sandbox Code Playgroud) 我从IntelliJ(Ultimate)IDE在tomcat 7上运行webapp时遇到了很大的问题.问题是,我无法taglib
为我的jsp工作.我试图添加什么样的taglib并不重要,无论如何它都无法正常工作.JSP只有taglibs:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="dec" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
Run Code Online (Sandbox Code Playgroud)
和异常(对于每个taglib):
23:50:22,420 ERROR UnhandledExceptionsFilter:34 - Unhandled exception:
java.lang.RuntimeException: org.apache.jasper.JasperException: The absolute uri: http://www.opensymphony.com/sitemesh/decorator cannot be resolved in either web.xml or the jar files deployed with this application
at com.opensymphony.sitemesh.webapp.decorator.BaseWebAppDecorator.render(BaseWebAppDecorator.java:39)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:84)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) …
Run Code Online (Sandbox Code Playgroud) 在触发事件"onkeyup"时获取输入数据我遇到了小问题.我有这样的输入和其他数据:
// El-cheapo model for form
private static final ValueMap cheapModel = new ValueMap();
//some code...
//...
Form form = new Form( "pushNotificationForm" );
form.setOutputMarkupId( true );
final Label actualSizeLabel = new Label( ACTUAL_NOTIFICATION_SIZE_ID, new Model<String>( actualSize ) );
actualSizeLabel.setOutputMarkupId( true );
final TextField<String> titleTextField = new TextField<String>( TITLE_TEXTFIELD_ID, new PropertyModel<String>(
cheapModel, TITLE_TEXTFIELD_ID ) );
titleTextField.setRequired( true );
titleTextField.add( new AjaxEventBehavior( "onkeyup" )
{
@Override
protected void onEvent( AjaxRequestTarget ajaxRequestTarget )
{
actualSize = Integer.toString( (getTitle() ).getBytes().length );
ajaxRequestTarget.add( actualSizeLabel …
Run Code Online (Sandbox Code Playgroud) 我发现(可能)用Oracle DB的标识符名称来解决我的问题非常有趣 - > http://code.google.com/p/hibernate-naming-strategy-for-oracle/ 但我很难让它工作用Spring MVC实现我的项目.
虽然我在每个地方添加了它是可能的,但不知何故spring并没有为我的Hibernate设置命名策略.
我的servlet-context.xml的一部分
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="oracle.jdbc.OracleDriver"/>
<property name="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"/>
<property name="user" value="xxx"/>
<property name="password" value="xxx"/>
<property name="maxPoolSize" value="10"/>
<property name="maxStatements" value="0"/>
<property name="minPoolSize" value="5"/>
</bean>
<bean id="namingStrategy" class="com.execon.OracleNamingStrategy"/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="namingStrategy" ref="namingStrategy"/>
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
<property name="packagesToScan" value="com.execon.models"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
和hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.ejb.naming_strategy">com.execon.OracleNamingStrategy</property>
</session-factory>
</hibernate-configuration> …
Run Code Online (Sandbox Code Playgroud) 是否可以指定时间,之后我可以显示忙碌指示符?
繁忙指标的代码非常简单:
jQuery.ajaxSetup( {
beforeSend:function ()
{
jQuery( "#busy-indicator" ).show();
}, complete:function ()
{
jQuery( "#busy-indicator" ).hide();
}
} );
Run Code Online (Sandbox Code Playgroud)
但是经常Ajax请求比出现指示器更快,因此我想显示它的请求,至少1秒钟,这可能吗?或者你知道怎么做吗?
我有通过varchar排序元素的问题,包含波兰字符,如±,Ą.
例如,我们有以下名称:
Aaaa
BBcvx
?ccc
Ddde
?dcc
Run Code Online (Sandbox Code Playgroud)
以下查询:
select * from something order by lower(name);
Run Code Online (Sandbox Code Playgroud)
返回结果如下:
Aaaa
BBcvx
Ddde
?dcc
?ccc
Run Code Online (Sandbox Code Playgroud)
如您所见,抛光字符被忽略并放在最后.它应该是:
Aaaa
?dcc
?ccc
BBcvx
Ddde
Run Code Online (Sandbox Code Playgroud)
可能是什么问题?数据库编码?我的是:
SELECT * FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER = 'NLS_CHARACTERSET';
Result:
EE8MSWIN1250
Run Code Online (Sandbox Code Playgroud)
可以在不更改数据库编码的情
当您键入电子邮件,旧密码,新密码并重复修改配置文件的新密码时,我会有一些基本形式.我想要实现的是在传球错误时显示反馈信息.一段代码看起来像这样:
public class EditProfileForm extends Form<Void>
{
private static final long serialVersionUID = 1L;
// El-cheapo model for form
private final ValueMap properties = new ValueMap();
private ModalWindow modalWindow;
@SpringBean
UserManager userManager;
@SpringBean
Validator validator;
private User user;
private static final String EMAIL = "mp-email";
private static final String OLD_PASS = "mp-oldpass";
private static final String NEW_PASS = "mp-newpass";
private static final String NEW_PASS_REPEAT = "mp-newpassrepeat";
private static final String ERROR_WRONG_PASS = "Wrong pass";
private static final String ERROR_PASS_DIFF = …
Run Code Online (Sandbox Code Playgroud) 在SO的任何地方只有选择器通过value
,但我想option
根据它选择文本.
例如,我有这个:
<select id="some-id">
<option>1</option>
<option>2</option>
</select>
Run Code Online (Sandbox Code Playgroud)
如何获得文本等于"2"的选项?像这样的东西:
jQuery("#some-id option[text='2']")
Run Code Online (Sandbox Code Playgroud)
但它不适合我,应该怎么做?
java ×4
jquery ×4
hibernate ×3
oracle ×3
javascript ×2
oracle11g ×2
spring ×2
spring-mvc ×2
wicket ×2
ajax ×1
arrays ×1
browser ×1
jstree ×1
openlayers ×1
performance ×1
php ×1
rendering ×1
sql ×1
sql-order-by ×1
tomcat7 ×1