2013-05-15 22 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