多import java.util.Date;/**
* Weather entity. @author MyEclipse Persistence Tools
*/public class Weather implements java.io.Serializable { // Fields private String guid;
private Station station;
private Date date;
private Date spiderDate;
private Short week;
private String bwea;
private String ewea;
private Short tmax;
private Short tmin;
private String bwind;
private String ewind;
private String bwindPower;
private String ewindPower; // Constructors /** default constructor */
public Weather() {
} /** full constructor */
public Weather(Station station, Date date, Date spiderDate, Short week,
String bwea, String ewea, Short tmax, Short tmin, String bwind,
String ewind, String bwindPower, String ewindPower) {
this.station = station;
this.date = date;
this.spiderDate = spiderDate;
this.week = week;
this.bwea = bwea;
this.ewea = ewea;
this.tmax = tmax;
this.tmin = tmin;
this.bwind = bwind;
this.ewind = ewind;
this.bwindPower = bwindPower;
this.ewindPower = ewindPower;
} get(),set()...............}
<?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.scyb.iptv.weather.common.bo.Weather" table="weather" catalog="weather_info">
<id name="guid" type="java.lang.String">
<column name="GUID" length="32" />
<generator class="uuid.hex" />
</id>
<many-to-one name="station" class="com.scyb.iptv.weather.common.bo.Station">
<column name="STATION_NO" length="32" unique="true">
<comment>站点号</comment>
</column>
</many-to-one>
<property name="date" type="java.util.Date">
<column name="DATE" length="10">
<comment>天气日期</comment>
</column>
</property>
<property name="spiderDate" type="java.util.Date">
<column name="SPIDER_DATE" length="10">
<comment>爬虫日期</comment>
</column>
</property>
<property name="week" type="java.lang.Short">
<column name="WEEK">
<comment>星期</comment>
</column>
</property>
<property name="bwea" type="java.lang.String">
<column name="BWEA" length="6">
<comment>白天天气</comment>
</column>
</property>
<property name="ewea" type="java.lang.String">
<column name="EWEA" length="6">
<comment>夜间天气</comment>
</column>
</property>
<property name="tmax" type="java.lang.Short">
<column name="TMAX">
<comment>最高温度</comment>
</column>
</property>
<property name="tmin" type="java.lang.Short">
<column name="TMIN">
<comment>最低温度</comment>
</column>
</property>
<property name="bwind" type="java.lang.String">
<column name="BWIND" length="6">
<comment>白天风向</comment>
</column>
</property>
<property name="ewind" type="java.lang.String">
<column name="EWIND" length="6">
<comment>夜间风向</comment>
</column>
</property>
<property name="bwindPower" type="java.lang.String">
<column name="BWIND_POWER" length="8">
<comment>白天风力</comment>
</column>
</property>
<property name="ewindPower" type="java.lang.String">
<column name="EWIND_POWER" length="8">
<comment>夜间风力</comment>
</column>
</property>
</class>
</hibernate-mapping>一
/**
* Station entity. @author MyEclipse Persistence Tools
*/public class Station implements java.io.Serializable { // Fields private Integer stationNo;
private String guid;
private String continent;
private String country;
private String province;
private String cityName;
private String counties;
private String url;
private Set weathers = new HashSet(0); // Constructors /** default constructor */
public Station() {
} /** full constructor */
public Station(String guid, String continent, String country,
String province, String cityName, String counties, String url,
Set weathers, Set exps) {
this.guid = guid;
this.continent = continent;
this.country = country;
this.province = province;
this.cityName = cityName;
this.counties = counties;
this.url = url;
this.weathers = weathers;
this.exps = exps;
} // Property accessors get(),set()...............}
<?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.scyb.iptv.weather.common.bo.Station" table="station" catalog="weather_info">
<id name="stationNo" type="java.lang.Integer">
<column name="STATION_NO" />
<generator class="uuid.hex" />
</id>
<property name="guid" type="java.lang.String">
<column name="GUID" length="32">
<comment>主键</comment>
</column>
</property>
<property name="continent" type="java.lang.String">
<column name="CONTINENT" length="8">
<comment>洲</comment>
</column>
</property>
<property name="country" type="java.lang.String">
<column name="COUNTRY" length="8">
<comment>国家</comment>
</column>
</property>
<property name="province" type="java.lang.String">
<column name="PROVINCE" length="8">
<comment>省</comment>
</column>
</property>
<property name="cityName" type="java.lang.String">
<column name="CITY_NAME" length="8">
<comment>市</comment>
</column>
</property>
<property name="counties" type="java.lang.String">
<column name="COUNTIES" length="8">
<comment>区县</comment>
</column>
</property>
<property name="url" type="java.lang.String">
<column name="URL" length="200">
<comment>天气网地址</comment>
</column>
</property>
<set name="weathers" inverse="true" lazy="true">
<key>
<column name="STATION_NO" unique="true">
<comment>站点号</comment>
</column>
</key>
<one-to-many class="com.scyb.iptv.weather.common.bo.Weather" />
</set>
</class>
</hibernate-mapping>
HQLString hql = "from Station as sta left join sta.weathers wea where wea.spiderDate = curdate() and wea.date = curdate() and sta.stationNo like '10101%'";
List list = this.queryList(hql);list.size()为什么是0,生成的SQL放在数据库里查询却有记录。
当把hql的where条件语句删掉后,再执行list.size()就能查到东西了。
需求:从Station,Weather中取几个属性的值,拼接在一起。条件就是spiderDate,date要当日的,stationNo要10101%的。
跪求正确HQL写法。
* Weather entity. @author MyEclipse Persistence Tools
*/public class Weather implements java.io.Serializable { // Fields private String guid;
private Station station;
private Date date;
private Date spiderDate;
private Short week;
private String bwea;
private String ewea;
private Short tmax;
private Short tmin;
private String bwind;
private String ewind;
private String bwindPower;
private String ewindPower; // Constructors /** default constructor */
public Weather() {
} /** full constructor */
public Weather(Station station, Date date, Date spiderDate, Short week,
String bwea, String ewea, Short tmax, Short tmin, String bwind,
String ewind, String bwindPower, String ewindPower) {
this.station = station;
this.date = date;
this.spiderDate = spiderDate;
this.week = week;
this.bwea = bwea;
this.ewea = ewea;
this.tmax = tmax;
this.tmin = tmin;
this.bwind = bwind;
this.ewind = ewind;
this.bwindPower = bwindPower;
this.ewindPower = ewindPower;
} get(),set()...............}
<?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.scyb.iptv.weather.common.bo.Weather" table="weather" catalog="weather_info">
<id name="guid" type="java.lang.String">
<column name="GUID" length="32" />
<generator class="uuid.hex" />
</id>
<many-to-one name="station" class="com.scyb.iptv.weather.common.bo.Station">
<column name="STATION_NO" length="32" unique="true">
<comment>站点号</comment>
</column>
</many-to-one>
<property name="date" type="java.util.Date">
<column name="DATE" length="10">
<comment>天气日期</comment>
</column>
</property>
<property name="spiderDate" type="java.util.Date">
<column name="SPIDER_DATE" length="10">
<comment>爬虫日期</comment>
</column>
</property>
<property name="week" type="java.lang.Short">
<column name="WEEK">
<comment>星期</comment>
</column>
</property>
<property name="bwea" type="java.lang.String">
<column name="BWEA" length="6">
<comment>白天天气</comment>
</column>
</property>
<property name="ewea" type="java.lang.String">
<column name="EWEA" length="6">
<comment>夜间天气</comment>
</column>
</property>
<property name="tmax" type="java.lang.Short">
<column name="TMAX">
<comment>最高温度</comment>
</column>
</property>
<property name="tmin" type="java.lang.Short">
<column name="TMIN">
<comment>最低温度</comment>
</column>
</property>
<property name="bwind" type="java.lang.String">
<column name="BWIND" length="6">
<comment>白天风向</comment>
</column>
</property>
<property name="ewind" type="java.lang.String">
<column name="EWIND" length="6">
<comment>夜间风向</comment>
</column>
</property>
<property name="bwindPower" type="java.lang.String">
<column name="BWIND_POWER" length="8">
<comment>白天风力</comment>
</column>
</property>
<property name="ewindPower" type="java.lang.String">
<column name="EWIND_POWER" length="8">
<comment>夜间风力</comment>
</column>
</property>
</class>
</hibernate-mapping>一
/**
* Station entity. @author MyEclipse Persistence Tools
*/public class Station implements java.io.Serializable { // Fields private Integer stationNo;
private String guid;
private String continent;
private String country;
private String province;
private String cityName;
private String counties;
private String url;
private Set weathers = new HashSet(0); // Constructors /** default constructor */
public Station() {
} /** full constructor */
public Station(String guid, String continent, String country,
String province, String cityName, String counties, String url,
Set weathers, Set exps) {
this.guid = guid;
this.continent = continent;
this.country = country;
this.province = province;
this.cityName = cityName;
this.counties = counties;
this.url = url;
this.weathers = weathers;
this.exps = exps;
} // Property accessors get(),set()...............}
<?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.scyb.iptv.weather.common.bo.Station" table="station" catalog="weather_info">
<id name="stationNo" type="java.lang.Integer">
<column name="STATION_NO" />
<generator class="uuid.hex" />
</id>
<property name="guid" type="java.lang.String">
<column name="GUID" length="32">
<comment>主键</comment>
</column>
</property>
<property name="continent" type="java.lang.String">
<column name="CONTINENT" length="8">
<comment>洲</comment>
</column>
</property>
<property name="country" type="java.lang.String">
<column name="COUNTRY" length="8">
<comment>国家</comment>
</column>
</property>
<property name="province" type="java.lang.String">
<column name="PROVINCE" length="8">
<comment>省</comment>
</column>
</property>
<property name="cityName" type="java.lang.String">
<column name="CITY_NAME" length="8">
<comment>市</comment>
</column>
</property>
<property name="counties" type="java.lang.String">
<column name="COUNTIES" length="8">
<comment>区县</comment>
</column>
</property>
<property name="url" type="java.lang.String">
<column name="URL" length="200">
<comment>天气网地址</comment>
</column>
</property>
<set name="weathers" inverse="true" lazy="true">
<key>
<column name="STATION_NO" unique="true">
<comment>站点号</comment>
</column>
</key>
<one-to-many class="com.scyb.iptv.weather.common.bo.Weather" />
</set>
</class>
</hibernate-mapping>
HQLString hql = "from Station as sta left join sta.weathers wea where wea.spiderDate = curdate() and wea.date = curdate() and sta.stationNo like '10101%'";
List list = this.queryList(hql);list.size()为什么是0,生成的SQL放在数据库里查询却有记录。
当把hql的where条件语句删掉后,再执行list.size()就能查到东西了。
需求:从Station,Weather中取几个属性的值,拼接在一起。条件就是spiderDate,date要当日的,stationNo要10101%的。
跪求正确HQL写法。
解决方案 »
- ********IBM FileNet和CMIS,有哪位大大用过,传授一下经验
- struts2配置,跳转到一个action并且带参数,并且必须是客户端跳转
- 求struts+Hibernate困惑,一直提示空指针和属性不匹配
- JavaEE新手求助
- J2EE Form-based Authentication
- 高手请看非常具有挑战性的算法(希望各位高手给出JAVA编写的怪物(V)的逃脱算法)
- ant运行问题,很菜的一个问题希望大家帮帮忙
- struts网站的页面的每种信息都对应一个formbean吗?
- 开发数据库应用时EJB采用CMP还是BMP,各有何特点?
- 全天在线:救急!!JB8调试EJB客户程序报错,如何纠错??!!!!
- 时间格式
- 请高手指教while循环问题
List list = this.queryList(hql);//返回的list是一个Weather的对象列表
List list = this.queryList(hql);
HQL标准里有left join , right join , inner join 啊。为什么用了就变SQL了?
兄弟,我照你的修改,没用外连接,查询结果list还是0记录啊。但是生成的SQL在数据库里能查到记录,跟我写的left join一个效果,是不是其它哪里有配置错误?帮我看下。