Setter只执行赋值操作,但声明会抛出ParseException;在Hibernate中。

huangapple go评论64阅读模式
英文:

Setter only does assignment, yet declares that it throws a ParseException; in Hibernate

问题

发现一个只执行典型赋值操作的Date设置器,但却有一个似乎没有充分理由的throws ParseException。在设置器的主体中没有进行Date构造。只有赋值操作。

这是在一个Hibernate实体上。设置器字段被注解为@Column,可为空,可插入和可更新。不确定这是否重要。

这明显有问题,应该通过移除throws来修复,还是在决定移除之前需要进行更多的研究?

英文:

Discovered a Date setter that only does the typical assignment, yet has a throws ParseException for what seems like no good reason. No Date construction is happening in the body of the setter. Just assignment.

This is on a Hibernate entity. The setters field is annotated with @Column as nullable, insertable, and updateable. Not sure if that matters.

Is this obviously wrong and should be fixed by removing the throws or is there more research to do before deciding to remove this?

答案1

得分: 1

根据你的描述,移除throws声明似乎是完全安全的。猜测可能是setter最初接受一个String并对其进行解析。如果你有源代码控制,可以查看历史记录以确认这一点。

英文:

From your description it sounds perfectly safe to remove the throws declaration. A guess would be that the setter originally took a String and parsed it. If you have source control, a check in the history might confirm this.

huangapple
  • 本文由 发表于 2023年7月11日 00:51:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76655815.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定