2013-05-15 24 views
1

我有使用其swing管理器的hsql服務器,我可以檢索數據正常。我有DAO使用JPA和當它的主要方法作爲獨立運行,它可以檢索相同的數據罰款。來自webapp的hsql springmvc jpa hibernate

當我現在使用JPA用SpringMVC從同樣的方法使用DAO被調用DAO上,我看到記錄正在執行相同的查詢,但它並沒有檢索到任何數據。

當我們通過springmvc使用jpa時,是否需要一些設置。

這裏用SpringMVC是從Tomcat日誌:

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 
[email protected]] 
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 

這裏是類似的日誌從獨立運行的道:

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 

問候,

米滕。

回答

0

我意識到,在檢查之間用於where子句那些雙值是一個問題。這些微小的差異導致了結果集的差異。請將此問題視爲用戶端的錯誤,以瞭解雙相關小數如何導致問題,並在需要時關閉/刪除此問題。米滕。

+0

你應該自己刪除它,因爲它不太可能幫助其他人。 – acdcjunior