来自webapp的hsql springmvc jpa hibernate

时间:2013-05-15 11:59:07

标签: hibernate spring-mvc jpa hsqldb

我有hsql服务器使用它的swing管理器我可以检索数据。 JDBC:HSQLDB:HSQL://本地主机:1234 / securityweb

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

当我现在使用来自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 run的类似日志:

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

此致

米滕。

1 个答案:

答案 0 :(得分:0)

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