小编Tom*_*icz的帖子

Hibernate slf4j异常

我打电话时收到以下异常 configuration.configure(hibernate.cfg.xml).buildSessionFactory():

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.Logger.isTraceEnabled()Z
    at org.hibernate.type.NullableType.<clinit>(NullableType.java:59)
    at org.hibernate.Hibernate.<clinit>(Hibernate.java:103)
    at org.hibernate.type.TypeFactory.<clinit>(TypeFactory.java:69)
    at org.hibernate.mapping.ManyToOne.getType(ManyToOne.java:49)
    at org.hibernate.mapping.ManyToOne.createForeignKey(ManyToOne.java:62)
    at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2213)
    at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2170)
    at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2060)
    at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:381)
    at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
    at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
    at org.hibernate.cfg.Configuration.add(Configuration.java:702)
    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:537)
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:599)
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1621)
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1589)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1568)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1542)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
    at com.enwelib.server.hibernate.helper.HibernateVendHelper.<init>(HibernateVendHelper.java:47)
    at com.ensarm.crawler.CrawlManager.saveEntity(CrawlManager.java:93)
    at com.ensarm.crawler.CrawlManager.main(CrawlManager.java:30)
Run Code Online (Sandbox Code Playgroud)

java logging hibernate slf4j nosuchmethoderror

3
推荐指数
1
解决办法
1547
查看次数

如何比较scala中的两种不同类型的对象?

当我在scala解释器中检查值时,如:

scala> 1==1.0000000000000001

res1: Boolean = true

scala> 1==1.000000000000001

res2: Boolean = false
Run Code Online (Sandbox Code Playgroud)

在这里,我没有得到与"scala编译器如何将这些解释为整数或浮点或双精度(和比较)"相关的清晰视图.

floating-point scala

3
推荐指数
1
解决办法
191
查看次数

为什么我在调用ExceptionPolicy.HandleException时遇到System.InvalidOperationException?

我正在开发一个测试程序,帮助我弄清楚如何使用Microsoft.Practices.EnterpriseLibrary.ExceptionHandling框架.该程序定义了几种自定义异常类型,并将自定义异常处理程序与每种类型相关 在运行时,程序会提示用户输入异常类型,抛出异常,并使用ExceptionHandling框架为异常类型调用适当的异常处理程序:

using System;
using System.Collections.Specialized;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;

namespace ConsoleApplication1
{
    public class AException  : Exception  { public AException(string message)  : base(message) { } }
    public class BException  : Exception  { public BException(string message)  : base(message) { } }
    public class BBException : BException { public BBException(string message) : base(message) { } }

    public class WrapperException : Exception
    {
        public WrapperException(Exception innerException)
            : base("Wrapped exception: [" + innerException.Message + "]", innerException) { }
    }

    public class …
Run Code Online (Sandbox Code Playgroud)

c# enterprise-library exception-handling exception

3
推荐指数
1
解决办法
6550
查看次数

如何在IntelliJ IDEA中设置默认系统文件编码

我希望IDEA使用任何默认的系统编码,而不是使用通过设置>文件编码设置的任何内容.哪个设置为UTF-8.

我的应用程序在Eclipse中运行良好,它在Windows上使用默认系统编码,但在通过IDEA运行应用程序时无法读取某些xmi文件.

file intellij-idea file-encodings

3
推荐指数
1
解决办法
9630
查看次数

使用... Pattern.compile()

使用java.util.regex.Pattern.compile()您可以将模式指定为参数.但是如何指定不区分大小写的标志并忽略空格呢?

java regex

2
推荐指数
1
解决办法
713
查看次数

2
推荐指数
1
解决办法
1345
查看次数

并发更新期间Hibernate StaleObjectStateException

我在Java J2EE Web应用程序中使用Hibernate 3.5.2和Spring Core 3.0.1.当单独的用户同时更新同一记录时,我得到一个StaleObjectStateExcpetion.事务由javax.persistence.EntityManager管理.以下是我创建问题的步骤.

  1. User1登录到应用程序
  2. User2登录到应用程序
  3. User1开始编辑recordA
  4. User2开始编辑recordA
  5. User1保存记录A.
  6. User2保存记录A.
  7. 抛出org.hibernate.StaleObjectStateException(见下文)

我已经读过这是由数据库中更新的版本号与该特定实体当前在内存中的版本号之间的差异引起的.但是,当我尝试使用查询或使用EntityManager.find()方法从数据库中查找当前版本号以从数据库中获取最新信息时,我发现版本号没有区别.我还试图手动并使用entityManager.merge(object)方法合并旧实体和新实体之间的更改,但没有运气.有关如何解决此问题的任何想法?

13290 [http-8080-7] ERROR org.hibernate.event.def.AbstractFlushingEventListener  - Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [edu.pitt.nmrl.med.domain.medical.MedicalHistory#362]
    at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1934)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2578)
    at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)
    at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
    at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1175)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1251)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:241)
    at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3.getResultList(CriteriaQueryCompiler.java:260)
    at edu.pitt.nmrl.med.services.SurveyService.checkMedicalDup(SurveyService.java:613)
    at edu.pitt.nmrl.med.services.SurveyService.save(SurveyService.java:790)
    at edu.pitt.nmrl.med.services.SurveyService$$FastClassByCGLIB$$b6424505.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
    at …
Run Code Online (Sandbox Code Playgroud)

spring hibernate java-ee

2
推荐指数
1
解决办法
7843
查看次数

对于最多10个元素的数组:for loop copy或System.arrayCopy?

假设Java中有10个或更少的Object [],那么复制数组的最快方法是什么?

  1. for(int i = 0;i < a.length;i++)
    
    Run Code Online (Sandbox Code Playgroud)
  2. for(int i = 0,l = a.length;i < l;i++) // i.e. is caching array len in local var faster?
    
    Run Code Online (Sandbox Code Playgroud)
  3. System.arrayCopy(a, 0, a2, 0, a.length);
    
    Run Code Online (Sandbox Code Playgroud)

java arrays copy

2
推荐指数
1
解决办法
271
查看次数

Spring安全密码hash + salt

我正在使用以明文形式存储密码的遗留应用程序.我已将应用程序移植到spring 3 mvc + security.我还成功地使用sha256 +基于用户名的盐来获得Spring安全性处理认证和授权.这一切都很好,但作为部署的一部分,我将需要迁移现有数据库以使用新密码模式.我不确定Spring安全性如何使用salt进行密码散列,因此我无法编写可用于将旧明文密码迁移到新sha256 + salt模式的sql脚本.是否有任何文档或资源可用于解决这个问题?

java spring salt spring-security saltedhash

2
推荐指数
1
解决办法
6653
查看次数

GWT XML替换类

<module>
<inherits name="com.google.gwt.core.Core"/>
<inherits name="com.google.gwt.user.UserAgent"/>
<inherits name="com.google.gwt.user.User"/>

<replace-with class="hu.goodimpress.szamlazo.ajax.client.utils.JSON.JsonReader">
<when-type-is class="com.extjs.gxt.ui.client.data.JsonReader"/>
<when-property-is name="user.agent" value="gecko1_8"/>
</replace-with>
<replace-with class="hu.goodimpress.szamlazo.ajax.client.utils.JSON.JsonReader">
<when-type-is class="com.extjs.gxt.ui.client.data.JsonReader"/>
<when-property-is name="user.agent" value="opera"/>
</replace-with>
<replace-with class="hu.goodimpress.szamlazo.ajax.client.utils.JSON.JsonReader">
<when-type-is class="com.extjs.gxt.ui.client.data.JsonReader"/>
<when-property-is name="user.agent" value="safari"/>
</replace-with>


<inherits name="com.extjs.gxt.ui.GXT"/>
<inherits name="hu.goodimpress.szamlazo.ajax.Start"/>


<entry-point class="hu.goodimpress.szamlazo.client.Szamlazo"/>
</module>
Run Code Online (Sandbox Code Playgroud)

但是gwt没有改变GXT JsonReader,我的JsonReader :((我使用调试模式....所以更容易替换从时间和地点派生的中心类,好像代码要少一些

为什么?

xml gwt gxt

2
推荐指数
1
解决办法
1662
查看次数