hibernate无主键情况下无法更新

系统有张表没有设置主键。只有几个字段,采用hibernate配置如下:

package com.bester.hw.domain;

/**
 * @author xjj email: exceljava@163.com 说明: 气象检测器报警条件表
 * @date Oct 20, 2008
 */
public class WeatherAlarmCondition implements java.io.Serializable {
	private WeatherAlarmConditionId id;

	public WeatherAlarmCondition() {
	}

	public WeatherAlarmCondition(WeatherAlarmConditionId id) {
		this.id = id;
	}

	public WeatherAlarmConditionId getId() {
		return this.id;
	}

	public void setId(WeatherAlarmConditionId id) {
		this.id = id;
	}

}

  

package com.bester.hw.domain;



/**
* @author xjj
* email: exceljava@163.com
* 说明:  气象监测器报警条件表。复合主键下的domain    
* @date Oct 20, 2008
*/
public class WeatherAlarmConditionId implements java.io.Serializable {

	//基础数据
	private Float visibilityMin;
	private Float visibilityMax;
	private Float roadTempMin;
	private Float roadTempMax;
	private Float roadbedTempMin;
	private Float roadbedTempMax;
	private Float sensorTempMin;
	private Float sensorTempMax;
	private Float saltTiterMin;
	private Float saltTiterMax;
	private Float freezingTempMin;
	private Float freezingTempMax;
	private Integer levigationHeightMin;
	private Integer levigationHeightMax;
	private Float rainGaugeMin;
	private Float rainGaugeMax;
	private Float windSpeedMin;
	private Float windSpeedMax;
	private Float tempMin;
	private Float tempMax;
	private Float humidityMin;
	private Float humidityMax;


	// Property accessors

	public Float getVisibilityMin() {
		return this.visibilityMin;
	}

	public void setVisibilityMin(Float visibilityMin) {
		this.visibilityMin = visibilityMin;
	}

	public Float getVisibilityMax() {
		return this.visibilityMax;
	}

	public void setVisibilityMax(Float visibilityMax) {
		this.visibilityMax = visibilityMax;
	}

	public Float getRoadTempMin() {
		return this.roadTempMin;
	}

	public void setRoadTempMin(Float roadTempMin) {
		this.roadTempMin = roadTempMin;
	}

	public Float getRoadTempMax() {
		return this.roadTempMax;
	}

	public void setRoadTempMax(Float roadTempMax) {
		this.roadTempMax = roadTempMax;
	}

	public Float getRoadbedTempMin() {
		return this.roadbedTempMin;
	}

	public void setRoadbedTempMin(Float roadbedTempMin) {
		this.roadbedTempMin = roadbedTempMin;
	}

	public Float getRoadbedTempMax() {
		return this.roadbedTempMax;
	}

	public void setRoadbedTempMax(Float roadbedTempMax) {
		this.roadbedTempMax = roadbedTempMax;
	}

	public Float getSensorTempMin() {
		return this.sensorTempMin;
	}

	public void setSensorTempMin(Float sensorTempMin) {
		this.sensorTempMin = sensorTempMin;
	}

	public Float getSensorTempMax() {
		return this.sensorTempMax;
	}

	public void setSensorTempMax(Float sensorTempMax) {
		this.sensorTempMax = sensorTempMax;
	}

	public Float getSaltTiterMin() {
		return this.saltTiterMin;
	}

	public void setSaltTiterMin(Float saltTiterMin) {
		this.saltTiterMin = saltTiterMin;
	}

	public Float getSaltTiterMax() {
		return this.saltTiterMax;
	}

	public void setSaltTiterMax(Float saltTiterMax) {
		this.saltTiterMax = saltTiterMax;
	}

	public Float getFreezingTempMin() {
		return this.freezingTempMin;
	}

	public void setFreezingTempMin(Float freezingTempMin) {
		this.freezingTempMin = freezingTempMin;
	}

	public Float getFreezingTempMax() {
		return this.freezingTempMax;
	}

	public void setFreezingTempMax(Float freezingTempMax) {
		this.freezingTempMax = freezingTempMax;
	}

	public Integer getLevigationHeightMin() {
		return this.levigationHeightMin;
	}

	public void setLevigationHeightMin(Integer levigationHeightMin) {
		this.levigationHeightMin = levigationHeightMin;
	}

	public Integer getLevigationHeightMax() {
		return this.levigationHeightMax;
	}

	public void setLevigationHeightMax(Integer levigationHeightMax) {
		this.levigationHeightMax = levigationHeightMax;
	}

	public Float getRainGaugeMin() {
		return this.rainGaugeMin;
	}

	public void setRainGaugeMin(Float rainGaugeMin) {
		this.rainGaugeMin = rainGaugeMin;
	}

	public Float getRainGaugeMax() {
		return this.rainGaugeMax;
	}

	public void setRainGaugeMax(Float rainGaugeMax) {
		this.rainGaugeMax = rainGaugeMax;
	}

	public Float getWindSpeedMin() {
		return this.windSpeedMin;
	}

	public void setWindSpeedMin(Float windSpeedMin) {
		this.windSpeedMin = windSpeedMin;
	}

	public Float getWindSpeedMax() {
		return this.windSpeedMax;
	}

	public void setWindSpeedMax(Float windSpeedMax) {
		this.windSpeedMax = windSpeedMax;
	}

	public Float getTempMin() {
		return this.tempMin;
	}

	public void setTempMin(Float tempMin) {
		this.tempMin = tempMin;
	}

	public Float getTempMax() {
		return this.tempMax;
	}

	public void setTempMax(Float tempMax) {
		this.tempMax = tempMax;
	}

	public Float getHumidityMin() {
		return this.humidityMin;
	}

	public void setHumidityMin(Float humidityMin) {
		this.humidityMin = humidityMin;
	}

	public Float getHumidityMax() {
		return this.humidityMax;
	}

	public void setHumidityMax(Float humidityMax) {
		this.humidityMax = humidityMax;
	}

	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof WeatherAlarmConditionId))
			return false;
		WeatherAlarmConditionId castOther = (WeatherAlarmConditionId) other;

		return ((this.getVisibilityMin() == castOther.getVisibilityMin()) || (this
				.getVisibilityMin() != null
				&& castOther.getVisibilityMin() != null && this
				.getVisibilityMin().equals(castOther.getVisibilityMin())))
				&& ((this.getVisibilityMax() == castOther.getVisibilityMax()) || (this
						.getVisibilityMax() != null
						&& castOther.getVisibilityMax() != null && this
						.getVisibilityMax()
						.equals(castOther.getVisibilityMax())))
				&& ((this.getRoadTempMin() == castOther.getRoadTempMin()) || (this
						.getRoadTempMin() != null
						&& castOther.getRoadTempMin() != null && this
						.getRoadTempMin().equals(castOther.getRoadTempMin())))
				&& ((this.getRoadTempMax() == castOther.getRoadTempMax()) || (this
						.getRoadTempMax() != null
						&& castOther.getRoadTempMax() != null && this
						.getRoadTempMax().equals(castOther.getRoadTempMax())))
				&& ((this.getRoadbedTempMin() == castOther.getRoadbedTempMin()) || (this
						.getRoadbedTempMin() != null
						&& castOther.getRoadbedTempMin() != null && this
						.getRoadbedTempMin().equals(
								castOther.getRoadbedTempMin())))
				&& ((this.getRoadbedTempMax() == castOther.getRoadbedTempMax()) || (this
						.getRoadbedTempMax() != null
						&& castOther.getRoadbedTempMax() != null && this
						.getRoadbedTempMax().equals(
								castOther.getRoadbedTempMax())))
				&& ((this.getSensorTempMin() == castOther.getSensorTempMin()) || (this
						.getSensorTempMin() != null
						&& castOther.getSensorTempMin() != null && this
						.getSensorTempMin()
						.equals(castOther.getSensorTempMin())))
				&& ((this.getSensorTempMax() == castOther.getSensorTempMax()) || (this
						.getSensorTempMax() != null
						&& castOther.getSensorTempMax() != null && this
						.getSensorTempMax()
						.equals(castOther.getSensorTempMax())))
				&& ((this.getSaltTiterMin() == castOther.getSaltTiterMin()) || (this
						.getSaltTiterMin() != null
						&& castOther.getSaltTiterMin() != null && this
						.getSaltTiterMin().equals(castOther.getSaltTiterMin())))
				&& ((this.getSaltTiterMax() == castOther.getSaltTiterMax()) || (this
						.getSaltTiterMax() != null
						&& castOther.getSaltTiterMax() != null && this
						.getSaltTiterMax().equals(castOther.getSaltTiterMax())))
				&& ((this.getFreezingTempMin() == castOther
						.getFreezingTempMin()) || (this.getFreezingTempMin() != null
						&& castOther.getFreezingTempMin() != null && this
						.getFreezingTempMin().equals(
								castOther.getFreezingTempMin())))
				&& ((this.getFreezingTempMax() == castOther
						.getFreezingTempMax()) || (this.getFreezingTempMax() != null
						&& castOther.getFreezingTempMax() != null && this
						.getFreezingTempMax().equals(
								castOther.getFreezingTempMax())))
				&& ((this.getLevigationHeightMin() == castOther
						.getLevigationHeightMin()) || (this
						.getLevigationHeightMin() != null
						&& castOther.getLevigationHeightMin() != null && this
						.getLevigationHeightMin().equals(
								castOther.getLevigationHeightMin())))
				&& ((this.getLevigationHeightMax() == castOther
						.getLevigationHeightMax()) || (this
						.getLevigationHeightMax() != null
						&& castOther.getLevigationHeightMax() != null && this
						.getLevigationHeightMax().equals(
								castOther.getLevigationHeightMax())))
				&& ((this.getRainGaugeMin() == castOther.getRainGaugeMin()) || (this
						.getRainGaugeMin() != null
						&& castOther.getRainGaugeMin() != null && this
						.getRainGaugeMin().equals(castOther.getRainGaugeMin())))
				&& ((this.getRainGaugeMax() == castOther.getRainGaugeMax()) || (this
						.getRainGaugeMax() != null
						&& castOther.getRainGaugeMax() != null && this
						.getRainGaugeMax().equals(castOther.getRainGaugeMax())))
				&& ((this.getWindSpeedMin() == castOther.getWindSpeedMin()) || (this
						.getWindSpeedMin() != null
						&& castOther.getWindSpeedMin() != null && this
						.getWindSpeedMin().equals(castOther.getWindSpeedMin())))
				&& ((this.getWindSpeedMax() == castOther.getWindSpeedMax()) || (this
						.getWindSpeedMax() != null
						&& castOther.getWindSpeedMax() != null && this
						.getWindSpeedMax().equals(castOther.getWindSpeedMax())))
				&& ((this.getTempMin() == castOther.getTempMin()) || (this
						.getTempMin() != null
						&& castOther.getTempMin() != null && this.getTempMin()
						.equals(castOther.getTempMin())))
				&& ((this.getTempMax() == castOther.getTempMax()) || (this
						.getTempMax() != null
						&& castOther.getTempMax() != null && this.getTempMax()
						.equals(castOther.getTempMax())))
				&& ((this.getHumidityMin() == castOther.getHumidityMin()) || (this
						.getHumidityMin() != null
						&& castOther.getHumidityMin() != null && this
						.getHumidityMin().equals(castOther.getHumidityMin())))
				&& ((this.getHumidityMax() == castOther.getHumidityMax()) || (this
						.getHumidityMax() != null
						&& castOther.getHumidityMax() != null && this
						.getHumidityMax().equals(castOther.getHumidityMax())));
	}

	public int hashCode() {
		int result = 17;

		result = 37
				* result
				+ (getVisibilityMin() == null ? 0 : this.getVisibilityMin()
						.hashCode());
		result = 37
				* result
				+ (getVisibilityMax() == null ? 0 : this.getVisibilityMax()
						.hashCode());
		result = 37
				* result
				+ (getRoadTempMin() == null ? 0 : this.getRoadTempMin()
						.hashCode());
		result = 37
				* result
				+ (getRoadTempMax() == null ? 0 : this.getRoadTempMax()
						.hashCode());
		result = 37
				* result
				+ (getRoadbedTempMin() == null ? 0 : this.getRoadbedTempMin()
						.hashCode());
		result = 37
				* result
				+ (getRoadbedTempMax() == null ? 0 : this.getRoadbedTempMax()
						.hashCode());
		result = 37
				* result
				+ (getSensorTempMin() == null ? 0 : this.getSensorTempMin()
						.hashCode());
		result = 37
				* result
				+ (getSensorTempMax() == null ? 0 : this.getSensorTempMax()
						.hashCode());
		result = 37
				* result
				+ (getSaltTiterMin() == null ? 0 : this.getSaltTiterMin()
						.hashCode());
		result = 37
				* result
				+ (getSaltTiterMax() == null ? 0 : this.getSaltTiterMax()
						.hashCode());
		result = 37
				* result
				+ (getFreezingTempMin() == null ? 0 : this.getFreezingTempMin()
						.hashCode());
		result = 37
				* result
				+ (getFreezingTempMax() == null ? 0 : this.getFreezingTempMax()
						.hashCode());
		result = 37
				* result
				+ (getLevigationHeightMin() == null ? 0 : this
						.getLevigationHeightMin().hashCode());
		result = 37
				* result
				+ (getLevigationHeightMax() == null ? 0 : this
						.getLevigationHeightMax().hashCode());
		result = 37
				* result
				+ (getRainGaugeMin() == null ? 0 : this.getRainGaugeMin()
						.hashCode());
		result = 37
				* result
				+ (getRainGaugeMax() == null ? 0 : this.getRainGaugeMax()
						.hashCode());
		result = 37
				* result
				+ (getWindSpeedMin() == null ? 0 : this.getWindSpeedMin()
						.hashCode());
		result = 37
				* result
				+ (getWindSpeedMax() == null ? 0 : this.getWindSpeedMax()
						.hashCode());
		result = 37 * result
				+ (getTempMin() == null ? 0 : this.getTempMin().hashCode());
		result = 37 * result
				+ (getTempMax() == null ? 0 : this.getTempMax().hashCode());
		result = 37
				* result
				+ (getHumidityMin() == null ? 0 : this.getHumidityMin()
						.hashCode());
		result = 37
				* result
				+ (getHumidityMax() == null ? 0 : this.getHumidityMax()
						.hashCode());
		return result;
	}

}

 配置文件如下:

<?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.bester.hw.domain.WeatherAlarmCondition" table="T_WEATHER_ALARM_CONDITION" schema="dbo" catalog="highway">
        <composite-id name="id" class="com.bester.hw.domain.WeatherAlarmConditionId">
            <key-property name="visibilityMin" type="java.lang.Float">
                <column name="visibility_min" precision="53" scale="0" />
            </key-property>
            <key-property name="visibilityMax" type="java.lang.Float">
                <column name="visibility_max" precision="53" scale="0" />
            </key-property>
            <key-property name="roadTempMin" type="java.lang.Float">
                <column name="road_temp_min" precision="53" scale="0" />
            </key-property>
            <key-property name="roadTempMax" type="java.lang.Float">
                <column name="road_temp_max" precision="53" scale="0" />
            </key-property>
            <key-property name="roadbedTempMin" type="java.lang.Float">
                <column name="roadbed_temp_min" precision="53" scale="0" />
            </key-property>
            <key-property name="roadbedTempMax" type="java.lang.Float">
                <column name="roadbed_temp_max" precision="53" scale="0" />
            </key-property>
            <key-property name="sensorTempMin" type="java.lang.Float">
                <column name="sensor_temp_min" precision="53" scale="0" />
            </key-property>
            <key-property name="sensorTempMax" type="java.lang.Float">
                <column name="sensor_temp_max" precision="53" scale="0" />
            </key-property>
            <key-property name="saltTiterMin" type="java.lang.Float">
                <column name="salt_titer_min" precision="53" scale="0" />
            </key-property>
            <key-property name="saltTiterMax" type="java.lang.Float">
                <column name="salt_titer_max" precision="53" scale="0" />
            </key-property>
            <key-property name="freezingTempMin" type="java.lang.Float">
                <column name="freezing_temp_min" precision="53" scale="0" />
            </key-property>
            <key-property name="freezingTempMax" type="java.lang.Float">
                <column name="freezing_temp_max" precision="53" scale="0" />
            </key-property>
            <key-property name="levigationHeightMin" type="java.lang.Integer">
                <column name="levigation_height_min" />
            </key-property>
            <key-property name="levigationHeightMax" type="java.lang.Integer">
                <column name="levigation_height_max" />
            </key-property>
            <key-property name="rainGaugeMin" type="java.lang.Float">
                <column name="rain_gauge_min" precision="53" scale="0" />
            </key-property>
            <key-property name="rainGaugeMax" type="java.lang.Float">
                <column name="rain_gauge_max" precision="53" scale="0" />
            </key-property>
            <key-property name="windSpeedMin" type="java.lang.Float">
                <column name="wind_speed_min" precision="53" scale="0" />
            </key-property>
            <key-property name="windSpeedMax" type="java.lang.Float">
                <column name="wind_speed_max" precision="53" scale="0" />
            </key-property>
            <key-property name="tempMin" type="java.lang.Float">
                <column name="temp_min" precision="53" scale="0" />
            </key-property>
            <key-property name="tempMax" type="java.lang.Float">
                <column name="temp_max" precision="53" scale="0" />
            </key-property>
            <key-property name="humidityMin" type="java.lang.Float">
                <column name="humidity_min" precision="53" scale="0" />
            </key-property>
            <key-property name="humidityMax" type="java.lang.Float">
                <column name="humidity_max" precision="53" scale="0" />
            </key-property>
        </composite-id>
    </class>
</hibernate-mapping>

 然后通过hibernate进行查找没有问题,可是就是无法进行更新。结合Struts2使用,代码如下:

	/**
	 * 功能:转向修改视图
	 * @return
	 * @date Oct 23, 2008
	 * @time 3:42:44 PM
	 */
	public String toUpdateAC(){
		List<WeatherAlarmCondition> wacList=cs.getWeatherAlarmConditionService().findAll(new WeatherAlarmCondition());
		if(wacList.size()!=0){
			ac=wacList.get(0);
		};
		this.initLog();
		return SUCCESS;
	}
	/**
	 * 功能:修改气象检测器报警条件
	 * @return
	 * @date Oct 23, 2008
	 * @time 3:49:21 PM
	 */
	public String updateAC(){
		cs.getWeatherAlarmConditionService().update(ac);
		this.operateString="修改气象检测器报警条件";
		return SUCCESS;
	}

 

如果使用saveOrUpdate,merge方法,则更改都变成了重新插入。如果用update方法,数据库数据无任何变化。难道没有主键的情况下,hibernate的session中不对对象的状态进行自动维护吗?

systermverilog中for循环中的fork join执行情况分析 仅为本人学习记录,如有错误感谢指正! 阅读详情

相关推荐

从硬件异常到代码救赎:RH850内存访问错误(MAE)的深层诊断与艺术

本文深入探讨瑞萨RH850微控制器的内存访问错误(MAE)诊断与解决方法。针对程序跑飞和Flash Driver交互中的潜在陷阱,提供系统性硬件异常分析框架和防御性编程实践,帮助嵌入式开发者从底层机制到代码层面有效预防和修复MAE问题,提升系统稳定性。

pytorch8learner的博客 197

没有主键的表,hibernate怎么去update

<br />有一个表,没有设置主键,又想update,怎么办?<br /> <br />发现这个表其实是可以有复合主键的,但是database里没有设置,而hibernate写annotation的时候又一定要设置主键@Id,如果你只设置一个,在update的时候会报错,因为一个键不是唯一,但是设置两个,hibernate又不允许。<br />用嵌套吧。<br /> <br /><br /><br /> import java.io.Serializable;<br /><br /> import ja

J2EE_ME的专栏 4245

FileZilla Server 1.2.0 TLS证书过期问题

FileZilla Server TLS证书过期后重新生成

Wigle的备忘录 7528

java hibernate 无主键表 更新

遇到这样的问题,用hibernate 开发,myeclipse 反向生成映射文件,现有表eventAlert,此表是个没有主键的表,生成的映射文件,如下: ...

my_jiera的博客 342

[LaTeX] 使用natbib宏包实现参考文献的“作者-年份”引用格式及常见编译错误排查

本文详细介绍了在LaTeX中使用natbib宏包实现参考文献“作者-年份”引用格式的完整流程。从宏包配置、.bib文件准备到标准编译步骤,重点解析了常见的“Bibliography not compatible with author-year”错误成因,并提供了彻底清理辅助文件等解决方案,帮助用户高效排版符合学术规范的参考文献。

moon9的博客 481

RK3588平台-ES8388音频驱动调试与设备树配置实战

本文详细解析了在RK3588平台上调试ES8388音频驱动的实战过程。内容涵盖Linux音频驱动的三层架构(Machine、Platform、Codec),并重点提供了设备树(DTS)的完整配置示例,包括I2C节点、声卡节点及音频路由设置。文章还分享了驱动加载验证、amixer调试命令以及常见问题(如无声、变调)的排查思路,旨在帮助开发者快速完成RK3588与ES8388的音频系统集成。

mango的博客 808

hibernate 没有id属性 怎么更新数据

248

DDR5内存ODT模式全解析:5种状态与实战配置指南(附时序图)

本文深入解析DDR5内存的片上终端电阻(ODT)机制,详细阐述了其五种核心状态(终结电阻禁用、RTT_WR、RTT_NOM_RD、RTT_NOM_WR、RTT_PARK)的定义、切换时序与工作原理。通过解读JESD79-5规范中的时序图,并提供基于模式寄存器的实战配置指南与代码示例,帮助硬件工程师和系统开发者优化信号完整性,解决高负载下的稳定性问题,并实现性能与功耗的最佳平衡。

weixin_29221753的博客 564

标记一下(hibernate update无主键表失败)

试验了一下,对无主键表更新不能成功,添加删除没问题 public class SsSysIpFilter implements Serializable { /** * */ private static final long serialVersionUID = 1L; private SsSysIpFilterId id; public Ss...

smiky的专栏 200

半导体制造技术导论(第二版)萧宏 第五章集成电路加热工艺答案

第二次退火是在较高温度下进行,并将电阻系数较高的c49碳化硅转变为电阻系数较低的c54碳。水平式高温炉加热、垂直式高温炉加热(即传统的管式炉加热)、快速加热工艺RTP、激光镭射。8. 集成电路芯片制造过程中,会使用垫底氧化层、阻挡氧化层、栅氧氧化层、屏蔽氧化层和全。氧化是最重要的加热过程之一,是一种添加工艺,将氧气加入到硅晶圆后,在晶圆表面形成二氧。为了满足元器件性能的要求,必须利用退火工艺将晶格的损伤修复,使其恢复单晶结构并激活掺。工艺氮气气流下将晶舟推入炉管,升高温度,稳定温度;

goal_achieving的博客 1864

79、昇腾系列服务器/昇腾系列推理卡/昇腾系列嵌入式开发板+Dify+one api部署DeepSeek-R1-Distill-Qwen-32BW8A8+RAG本地模型知识库和负载均衡双实例

阶段,安装过程缺什么,,在docker外面git下源码,进入容器内部进行量化,这里的容器建议在创建个8卡的容器,双卡容器量化会显示npu显存不够,除非你用cpu转模型,我就懒得创建容器了,使用cpu量化吧,巨慢;创建容器,进入容器,计划使用两张昇腾NPU卡推理DeepSeek-R1-Distill-Qwen-32B的W8A8模型,所以构建的容器用两张卡,选6、7卡吧,0-6号卡可以跑文本嵌入模型、重排序模型;直接进入量化阶段,在容器外面操作即可,环境不用管,因为系统已经默认配置了环境,直接跳到。

sxj731533730 6121

Hibernate 的级联更新

Hibernate 的实体更新,让我在开发的过程中,感受到了省心和劳心。

尽力而为 1524

3.1 快速启动Flink集群

在本实战中,我们将快速启动Apache Flink 1.13.0集群,并在Hadoop集群环境中提交作业。首先,我们会在本地下载Flink安装包并上传至云主机,解压并配置环境变量。接着,我们将启动Flink集群,通过访问Web UI进行监控管理。然后,我们会配置集群,将Flink分发到从节点,并在集群上提交作业。最后,我们将通过命令行提交作业,并在Web UI上查看任务节点的输出结果。这个过程涵盖了Flink集群的部署、配置和作业提交,为大数据处理提供了一个完整的实战经验。

howard2005的专栏 727

标记(hibernate查询无主键表出现null值)

hibernate在查询无主键表时,当查询的某行有某个字段出现空值时,那么返回的这一行的结果对象将会是null List&lt;SsSysIpFilterId&gt; ids = hibernateTemplate.find("s.id from SsSysIpFilter s")  ArrayList的add方法在添加一个null值时不会做任何判断,它会将null添加,并且长度加...

smiky的专栏 281

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Hibernate 更新部分更改的字段 hibernate update

Hibernate 中如果直接使用  Session.update(Object o); 或则是Session.updateOrUpdate(Object o);  会把这个表中的所有字段更新一遍。  如: ExperClass4k e = new ExperClass4k(); e.setTime(time); e.setQ_num(q_num); e.setK(k

OOM 3万+

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

hibernate编辑实体日期的更新问题

前言对于刚刚接触hibernate的开发者来说,它确实是一个伟大的东西,但如果针对修改不太明白的话,那确实挺伤的。首先修改是根据id查找到实体。然后和保存一样,也是用save进行存储。针对一些cdate创建日期,udate更新日期。我们希望创建日期只在添加是实体的时候创建,但是修改实体的时候cdate不发生改变,但是udate是在每次更新实体的时候改变,包括添加实体的时候。好了废话,不多说。开始吧!

HealerJean梦想博客 1512

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

hibernate使用注解无法进行更新操作的解决方法

1.一般来说,在多对多的双向关联中,往往是修改频繁的一方放弃外键维护。但在实际运用时要灵活选择,如学生选课中,按照前边那个约定,应该是课程一方维护外键,但若程序中是按照学号查找一个学生选了哪些课,而不是查询一门课由哪些学生选择,则应该由学生端维护外键。否则会出现无法更新课程的问题。如原来的写法 Course和Student实体类 @Entity @Table(name="t_course"

apologize的学习之路 1832

hibernate 更新数据的几种方式

方式一: 使用hibernate的缓存和快照机制, hibernate 向一级缓存放入数据时,同时保存快照数据 ( 数据库备份 ) ,当修改一级缓存数据,在 flush 操作时,对比缓存和快照,如果不一致,自动更新 ( 将缓存的内容同步到数据库,更新快照 ). /** 2. * 测试快照区的使用 3. */ 4. @Test 5. public voi...

Dug_Zhang的博客 3140

hibernate 更新所有字段问题

今天遇到一个问题; 在一个非事务方法A中,调用Bservice获取B对象; 对B对象的一个字段进行赋值,B.setB1("B1"); 调用Bservice的update方法,update方法直接用hibernate的updateObject方法进行保存。 debug模式下,show-sql=true 结果发现:所有的字段都更新了,update B set B1=?,B2=?,B3=? w

zhougod520的博客 1775

有关Hibernate/JPA的批量插入更新

​ 本文将研究如何使用Hibernate/JPA进行批量插入或更新实体。批量处理使我们可以在单个网络调用中向数据库发送一组SQL语句。这样,可以优化应用程序的网络和内存使用率。 1、创建实体 ​ 首先,创建一个School实体: @Entity @Data public class School { @Id @GeneratedValue(strategy = Generati...

hongye_student的博客 5172

Hibernate update 只更新被修改字段

Hibernate 中如果直接使用 Session.update(Object o); 会把这个表中的所有字段更新一遍。 如果我们只更改了state属性,而Hibernate 的sql语句 把所有字段都更改了一次。 这样要是我们有字段是文本类型,这个类型存储的内容是几千,几万字,这样效率会很低。 那么怎么只更改我们更新的

u012038649的专栏 1万+

java hibernate更新_Hibernate更新某些字段的几种update方法

Hibernate 中如果直接使用Session.update(Object o);会把这个表中的所有字段更新一遍。比如:publicclassTeacherTest{@Testpublicvoidupdate(){Sessionsession=HibernateUitl.getSessionFactory().getCurrentSession();session.beginT...

weixin_36442042的博客 724

hibernate 动态更新

dynamic-update (optional - defaults to false): specifies that UPDATE SQL should be generated at runtime and can contain only those columns whose values have changed. Take into account that dynami

信息系统开发 723

hibernate中save无法进行更新 只会执行新增操作

hibernate中save无法进行更新 只会执行新增操作

liketpp的博客 729

hibernate自动提交更新的问题

在项目中遇到的记录一下 大致场景伪代码如下: //查询到对象user User user = session.get(User.class,1); //根据user的属性gender(存的是code)查出对应的name Gender gender = session.creatQuery("form Gender where code = '"+a.getGender()+"'").list...

a316883923的博客 1660

奇怪问题:Hibernate 无法更新(update)

今天遇到一个很奇怪的问题,我用Hibernate,更新(update)时,无法更新,没有任何报错,卡在那里半天不动,只得强制关闭。 但是有时候突然更新可以正常。   浪费了我半天时间。后来发现重启eclipse 后可以正常。   于是最后发现我用的jOra DB,链接后就会卡死,无法更新现象,不知道是否与其有关系。?不知谁有遇到过?   Platform pf = (Platform...

982
上一篇: rails本地安装
下一篇: java平台下通过jacob对excel,word进行打印等操作
excellentjava
博客等级 码龄20年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值