mysql数据库里有数据,但是一直都查询不出来!求指教
数据库里的数据:
001ad30dd8fa447792c159cf23ac3b2b2012-05-2500:00:00ECP_HZMSCe331420
00268a0381884a90b9f06319b15cc6c82012-05-2500:00:00ECP_HZMSCe3318710
00289813c1724e35b9c982cf669d11d22012-05-2500:00:00ECP_HZMSCe331301
002afe0d601346af8db5d258f81763fd2012-05-2500:00:00ECP_HZMSCe330441
002e83d134b94594bf2a7a128a54d01e2012-05-2500:00:00ECP_HZMSCe331252
002eb79652da4e60965415488e0c02762012-05-2500:00:00ECP_HZMSCe3310382
0037e71f46d149e7836e62409d5620892012-05-2500:00:00ECP_HZMSCe332310
0070ddc1953f4200b2e69188c21b2d012012-05-2500:00:00ECP_HZMSCe3318173
00a4110add9946bf891703ca94a6c38b2012-05-2500:00:00ECP_HZMSCe331890
00aaab34dec744a18000d71ca35ca3742012-05-2500:00:00ECP_HZMSCe3314840
java代码:
System.err.println(date);
List<THeadercarr> list = getSession().createCriteria(THeadercarr.class).add(Restrictions.eq("date",date))
.add(Restrictions.eq("time", time)).list();
System.err.println(list.size());
这样子查询一直都查不出数据来,date和time都有值!最让我纠结的是,上边的数据是现在其他地方查询出来然后插入数据库的,我第一次插入后查就查不出来,然后同样的数据,再插入一次,就会把两次的数据都查询来!
THeadercarr.hbm.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.pojos.THeadercarr" table="t_headercarr" catalog="cnetwdas">
<id name="uuid" type="string">
<column name="uuid" length="32" />
<generator class="assigned" />
</id>
<property name="date" type="string">
<column name="date" length="50" />
</property>
<property name="time" type="string">
<column name="time" length="50" />
</property>
<property name="ecp" type="string">
<column name="ecp" length="100" />
</property>
<property name="cell" type="string">
<column name="cell" length="10" />
</property>
<property name="sector" type="string">
<column name="sector" length="10" />
</property>
<property name="carrier" type="string">
<column name="carrier" length="10" />
</property>
<property name="cellVersion" type="string">
<column name="cell_version" length="100" />
</property>
</class>
</hibernate-mapping>
[解决办法]
LZ分析一下HQL转化为的SQL能不能查出来?
[解决办法]
感觉你要多试试把配置文件换换地方,或者在spring.xml里改一下顺序。。。仔细的找一遍问题。我以前也遇到过。。很纠结。。。多试试,
[解决办法]
你是不是先插入接着就查询的?
如果是这样,可能因为插入的数据还没有同步到数据库,在插入之后flush一下再查询