1

我有 hsql 服务器,它使用它的 swing 管理器可以很好地检索数据。jdbc:hsqldb:hsql://localhost:1234/securityweb

我有使用 JPA 的 DAO,当使用它的主要方法作为独立运行时,它可以很好地检索相同的数据。

当我现在使用 springmvc 中的 JPA 使用 DAO 时,在 DAO 上调用了相同的方法,我在日志中看到正在执行相同的查询,但它没有检索任何数据。

当我们通过springmvc使用jpa时是否需要一些设置。

这是来自tomcat的springmvc日志:

17:21:35,668 DEBUG RequestMappingHandlerMapping:226 - Looking up handler method
for path /user/9869002979/19.1/73.1
17:21:35,668 DEBUG RequestMappingHandlerMapping:233 - Returning handler method [
public java.util.List<com.ril.jio.mhood.securityjpa.UserLocation> com.ril.jio.mh
ood.service.SecurityService.findLocations(java.lang.String,double,double)]
17:21:35,668 DEBUG DefaultListableBeanFactory:246 - Returning cached instance of
 singleton bean 'securityService'
17:21:35,668 DEBUG DispatcherServlet:912 - Last-Modified value for [/security/us
er/9869002979/19.1/73.1] is: -1
17:21:35,668 DEBUG SecurityService:42 - findLocations: phone=9869002979 latitude
=19.100000 longitude=73.000000
17:21:35,683  INFO LogHelper:46 - HHH000204: Processing PersistenceUnitInfo [
        name: securityjpaPU
        ...]
17:21:35,699  INFO DriverManagerConnectionProviderImpl:100 - HHH000402: Using Hi
bernate built-in connection pool (not for production use!)
17:21:35,699  INFO DriverManagerConnectionProviderImpl:137 - HHH000115: Hibernat
e connection pool size: 20
17:21:35,699  INFO DriverManagerConnectionProviderImpl:140 - HHH000006: Autocomm
it mode: false
17:21:35,699  INFO DriverManagerConnectionProviderImpl:156 - HHH000401: using dr
iver [org.hsqldb.jdbcDriver] at URL [jdbc:hsqldb:hsql://localhost:1234/securityw
eb]
17:21:35,699  INFO DriverManagerConnectionProviderImpl:162 - HHH000046: Connecti
on properties: {user=SA, password=****}
17:21:35,824  INFO Dialect:140 - HHH000400: Using dialect: org.hibernate.dialect
.HSQLDialect
17:21:35,824  INFO ASTQueryTranslatorFactory:48 - HHH000397: Using ASTQueryTrans
latorFactory
17:21:35,886  WARN EntityManagerFactoryRegistry:80 - HHH000436: Entity manager f
actory name (securityjpaPU) is already registered.  If entity manager will be cl
ustered or passivated, specify a unique value for property 'hibernate.ejb.entity
manager_factory_name'
Hibernate:
    select
        userlocati0_.phoneNumber as phoneNum1_0_,
        userlocati0_.lastTouched as lastTouc2_0_,
        userlocati0_.latitude as latitude3_0_,
        userlocati0_.longitude as longitud4_0_
    from
        PUBLIC.USERLOCATION userlocati0_
    where
        userlocati0_.phoneNumber<>?
        and (
            userlocati0_.latitude between 9.100000000000001 and 29.1
        )
        and (
            userlocati0_.longitude between 63.0 and 83.0
        )
    order by
        userlocati0_.lastTouched desc
Size: 0
Size: 0
17:21:35,933 DEBUG RequestResponseBodyMethodProcessor:150 - Written [[]] as "app
lication/json;charset=UTF-8" using [org.springframework.http.converter.json.Mapp
ingJacksonHttpMessageConverter@1013dc8]
17:21:35,933 DEBUG DispatcherServlet:999 - Null ModelAndView returned to Dispatc
herServlet with name 'mvc-dispatcher': assuming HandlerAdapter completed request
 handling
17:21:35,933 DEBUG DispatcherServlet:966 - Successfully completed request

这是来自独立 dao 运行的类似日志:

16:59:31,107 DEBUG logging:54 - Logging Provider: org.jboss.logging.Log4jLoggerProvider
16:59:31,201  INFO LogHelper:46 - HHH000204: Processing PersistenceUnitInfo [
    name: securityjpaPU
    ...]
16:59:31,264  INFO Version:54 - HHH000412: Hibernate Core {4.3.0.Beta2}
16:59:31,264  INFO Environment:239 - HHH000206: hibernate.properties not found
16:59:31,264  INFO Environment:342 - HHH000021: Bytecode provider name : javassist
16:59:31,420  INFO Version:37 - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
16:59:31,451  INFO DriverManagerConnectionProviderImpl:100 - HHH000402: Using Hibernate built-in connection pool (not for production use!)
16:59:31,451  INFO DriverManagerConnectionProviderImpl:137 - HHH000115: Hibernate connection pool size: 20
16:59:31,451  INFO DriverManagerConnectionProviderImpl:140 - HHH000006: Autocommit mode: false
16:59:31,451  INFO DriverManagerConnectionProviderImpl:156 - HHH000401: using driver [org.hsqldb.jdbcDriver] at URL [jdbc:hsqldb:hsql://localhost:1234/securityweb]
16:59:31,451  INFO DriverManagerConnectionProviderImpl:162 - HHH000046: Connection properties: {user=SA, password=****}
16:59:31,669  INFO Dialect:140 - HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
16:59:31,810  INFO ASTQueryTranslatorFactory:48 - HHH000397: Using ASTQueryTranslatorFactory
Hibernate: 
    select
        userlocati0_.phoneNumber as phoneNum1_0_,
        userlocati0_.lastTouched as lastTouc2_0_,
        userlocati0_.latitude as latitude3_0_,
        userlocati0_.longitude as longitud4_0_ 
    from
        PUBLIC.USERLOCATION userlocati0_ 
    where
        userlocati0_.phoneNumber<>? 
        and (
            userlocati0_.latitude between 9.100000000000001 and 29.1
        ) 
        and (
            userlocati0_.longitude between 63.099999999999994 and 83.1
        ) 
    order by
        userlocati0_.lastTouched desc
com.ril.jio.mhood.securityjpa.UserLocation[ PhoneNumber=9004060416 Latitude=29.100000 Longitude=83.100000 timestamp=2013-05-15 15:17:46.972
Size: 1
Size: 1

问候,

米腾。

4

1 回答 1

0

我意识到用于检查之间的 where 子句中的那些双值是一个问题。这些微小的差异导致了结果集的差异。请将此问题视为用户端的错误,因为他对双相关小数如何导致问题的理解以及如果需要关闭/删除此问题。米腾。

于 2013-05-18T05:55:31.223 回答